home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / m2 / m2_part1.lha / modula / src / Dos.def < prev    next >
Text File  |  1994-07-30  |  73KB  |  1,947 lines

  1. DEFINITION FOR LIBRARY MODULE Dos ;
  2.  
  3. FROM SYSTEM    IMPORT ADDRESS, BADDRESS, SHORTSET, LONGSET, STRING, LONGWORD ;
  4.  
  5. FROM Exec    IMPORT Library, Message, MessagePtr, MsgPort, MsgPortPtr, Task,
  6.                TaskPtr, MinList, LibraryPtr, MinNode, MinNodePtr,
  7.                SignalSemaphore, Node, NodePtr ;
  8.  
  9. FROM Utility    IMPORT HookPtr, TagItemPtr, TAG_USER ;
  10.  
  11.  
  12. TYPE
  13.   DevInfoPtr          = BCPL POINTER TO DevInfo    ;
  14.   FileHandlePtr          = BCPL POINTER TO FileHandle    ;
  15.   DosInfoPtr           = BCPL POINTER TO DosInfo    ;
  16.   DeviceListPtr       = BCPL POINTER TO DeviceList    ;
  17.   DosListPtr           = BCPL POINTER TO DosList    ;
  18.   FileLockPtr           = BCPL POINTER TO FileLock    ;
  19.   DosEnvecPtr           = BCPL POINTER TO DosEnvec    ;
  20.   FileSysStartupMsgPtr    = BCPL POINTER TO FileSysStartupMsg    ;
  21.   CommandLineInterfacePtr = BCPL POINTER TO CommandLineInterface ;
  22.  
  23.   DateStampPtr           = POINTER TO DateStampRec    ;
  24.   FileInfoBlockPtr       = POINTER TO FileInfoBlock    ;
  25.   InfoDataPtr           = POINTER TO InfoData        ;
  26.   ProcessPtr           = POINTER TO Process        ;
  27.   DosPacketPtr           = POINTER TO DosPacket    ;
  28.   StandardPacketPtr       = POINTER TO StandardPacket    ;
  29.   ErrorStringPtr       = POINTER TO ErrorString    ;
  30.   DosLibraryPtr       = POINTER TO DosLibrary    ;
  31.   RootNodePtr           = POINTER TO RootNode        ;
  32.   CliProcListPtr       = POINTER TO CliProcList    ;
  33.   AssignListPtr       = POINTER TO AssignList    ;
  34.   DevProcPtr           = POINTER TO DevProc        ;
  35.   DateTimePtr           = POINTER TO DateTime        ;
  36.   AnchorPathPtr       = POINTER TO AnchorPath    ;
  37.   AChainPtr           = POINTER TO AChain        ;
  38.   ExAllDataPtr           = POINTER TO ExAllData    ;
  39.   ExAllControlPtr       = POINTER TO ExAllControl    ;
  40.   DeviceNodePtr       = POINTER TO DeviceNode    ;
  41.   NotifyMessagePtr       = POINTER TO NotifyMessage    ;
  42.   NotifyRequestPtr       = POINTER TO NotifyRequest    ;
  43.   CSourcePtr           = POINTER TO CSource        ;
  44.   RDArgsPtr           = POINTER TO RDArgs        ;
  45.   RecordLockPtr       = POINTER TO RecordLock    ;
  46.   LocalVarPtr           = POINTER TO LocalVar        ;
  47.   SegmentPtr           = POINTER TO Segment        ;
  48.  
  49. CONST
  50.   DOSNAME = "dos.library" ;
  51.  
  52. (* Predefined Amiga DOS global constants *)
  53.  
  54. CONST
  55.   DOSTRUE  = -1 ;
  56.   DOSFALSE =  0 ;
  57.  
  58. (* Mode parameter to Open() *)
  59.  
  60. CONST
  61.   MODE_OLDFILE = 1005 ;  (* Open existing file read/write      *)
  62.                (* positioned at beginning of file.       *)
  63.  
  64.   MODE_NEWFILE = 1006 ;  (* Open freshly created file (delete     *)
  65.              (* old file) read/write, exclusive lock. *)
  66.  
  67.   MODE_READWRITE = 1004 ;(* Open old file w/shared lock,   *)
  68.              (* creates file if doesn't exist. *)
  69.  
  70. (* Relative position to Seek() *)
  71.  
  72.   OFFSET_BEGINNING = -1 ; (* relative to Begining Of File      *)
  73.   OFFSET_CURRENT   =  0    ; (* relative to Current file position *)
  74.   OFFSET_END       =  1    ; (* relative to End Of File           *)
  75.  
  76.   OFFSET_BEGINING  = OFFSET_BEGINNING ; (* ancient compatibility *)
  77.  
  78.   BITSPERBYTE       = 8  ;
  79.   BYTESPERLONG       = 4  ;
  80.   BITSPERLONG       = 32 ;
  81.   MAXINT       = 07FFFFFFFH ;
  82.   MININT       = 080000000H ;
  83.  
  84. (* Passed as type to Lock() *)
  85.   SHARED_LOCK       = -2    ; (* File is readable by others   *)
  86.   ACCESS_READ       = -2    ; (* Synonym              *)
  87.   EXCLUSIVE_LOCK   = -1    ; (* No other access allowed      *)
  88.   ACCESS_WRITE       = -1    ; (* Synonym              *)
  89.  
  90. TYPE
  91.   DateStampRec = RECORD   (* name clash with function DateStamp *)
  92.     ds_Days   : LONGINT ; (* Number of days since Jan. 1, 1978  *)
  93.     ds_Minute : LONGINT ; (* Number of minutes past midnight    *)
  94.     ds_Tick   : LONGINT ; (* Number of ticks past minute        *)
  95.   END ; (* DateStamp *)
  96.  
  97. CONST
  98.   TICKS_PER_SECOND = 50 ; (* Number of ticks in one second     *)
  99.  
  100. TYPE
  101. (* Returned by Examine() and ExNext(), must be on a 4 byte boundary *)
  102.   FileInfoBlock = RECORD
  103.     fib_DiskKey      : LONGINT ;
  104.     fib_DirEntryType : LONGINT ;  (* Type of Directory. If < 0, then a plain *)
  105.                       (* file. If > 0 a directory             *)
  106.     fib_FileName     : ARRAY [0..107] OF CHAR ;
  107.                       (* Null terminated.Max 30 chars used for now*)
  108.     fib_Protection   : LONGSET ;  (* bit mask of protection, rwxd are 3-0.    *)
  109.     fib_EntryType    : LONGINT ;
  110.     fib_Size         : LONGINT ;  (* Number of bytes in file  *)
  111.     fib_NumBlocks    : LONGINT ;  (* Number of blocks in file *)
  112.     fib_Date         : DateStampRec; (* Date file last changed   *)
  113.     fib_Comment         : ARRAY [0..79] OF CHAR ;
  114.                           (*0C terminated comment associated with file*)
  115.  
  116.     (* Note: the following fields are not supported by all filesystems.     *)
  117.     (* They should be initialized to 0 sending an ACTION_EXAMINE packet. *)
  118.     (* When Examine() is called, these are set to 0 for you.         *)
  119.     (* AllocDosObject() also initializes them to 0.             *)
  120.  
  121.     fib_OwnerUID     : CARDINAL ;        (* owner's UID *)
  122.     fib_OwnerGID     : CARDINAL ;        (* owner's GID *)
  123.  
  124.     fib_Reserved     : ARRAY [0..31] OF CHAR ;
  125.   END ; (* FileInfoBlock *)
  126.  
  127. (* FIB stands for FileInfoBlock *)
  128.  
  129. (* FIBB are bit definitions, FIBF are field definitions              *)
  130. (* Regular RWED bits are 0 == allowed.                      *)
  131. (* NOTE: GRP and OTR RWED permissions are 0 == not allowed!          *)
  132. (* Group and Other permissions are not directly handled by the filesystem *)
  133.  
  134. CONST
  135.   FIBB_OTR_READ       = 15 ; (* Other: file is readable            *)
  136.   FIBB_OTR_WRITE   = 14 ; (* Other: file is writable            *)
  137.   FIBB_OTR_EXECUTE = 13 ; (* Other: file is executable            *)
  138.   FIBB_OTR_DELETE  = 12 ; (* Other: prevent file from being deleted *)
  139.   FIBB_GRP_READ       = 11 ; (* Group: file is readable            *)
  140.   FIBB_GRP_WRITE   = 10 ; (* Group: file is writable            *)
  141.   FIBB_GRP_EXECUTE =  9 ; (* Group: file is executable            *)
  142.   FIBB_GRP_DELETE  =  8 ; (* Group: prevent file from being deleted *)
  143.  
  144.   FIBB_SCRIPT      = 6 ; (* program is a script (execute) file      *)
  145.   FIBB_PURE        = 5 ; (* program is reentrant and rexecutable    *)
  146.   FIBB_ARCHIVE     = 4 ; (* cleared whenever file is changed        *)
  147.   FIBB_READ        = 3 ; (* ignored by old filesystem            *)
  148.   FIBB_WRITE       = 2 ; (* ignored by old filesystem            *)
  149.   FIBB_EXECUTE     = 1 ; (* ignored by system, used by Shell        *)
  150.   FIBB_DELETE      = 0 ; (* prevent file from being deleted         *)
  151.  
  152.   FIBF_OTR_READ       = {FIBB_OTR_READ}    ;
  153.   FIBF_OTR_WRITE   = {FIBB_OTR_WRITE}   ;
  154.   FIBF_OTR_EXECUTE = {FIBB_OTR_EXECUTE} ;
  155.   FIBF_OTR_DELETE  = {FIBB_OTR_DELETE}  ;
  156.   FIBF_GRP_READ       = {FIBB_GRP_READ}    ;
  157.   FIBF_GRP_WRITE   = {FIBB_GRP_WRITE}   ;
  158.   FIBF_GRP_EXECUTE = {FIBB_GRP_EXECUTE} ;
  159.   FIBF_GRP_DELETE  = {FIBB_GRP_DELETE}  ;
  160.  
  161.   FIBF_SCRIPT      = {FIBB_SCRIPT}  ;
  162.   FIBF_PURE        = {FIBB_PURE}    ;
  163.   FIBF_ARCHIVE     = {FIBB_ARCHIVE} ;
  164.   FIBF_READ        = {FIBB_READ}    ;
  165.   FIBF_WRITE       = {FIBB_WRITE}   ;
  166.   FIBF_EXECUTE     = {FIBB_EXECUTE} ;
  167.   FIBF_DELETE      = {FIBB_DELETE}  ;
  168.  
  169. (* Standard maximum length for an error string from fault.  However, most *)
  170. (* error strings should be kept under 60 characters if possible.  Don't   *)
  171. (* forget space for the header you pass in.                  *)
  172.   FAULT_MAX = 82 ;
  173.  
  174. (* BCPL strings have a length in the first byte and then the characters.  *)
  175. (* For example:     s[0]=3 s[1]=S s[2]=Y s[3]=S                  *)
  176.  
  177. TYPE
  178.   BSTRING = BCPL POINTER TO ARRAY OF CHAR ;
  179.  
  180. (* returned by Info(), must be on a 4 byte boundary *)
  181. TYPE
  182.   InfoData = RECORD
  183.     id_NumSoftErrors : LONGINT ; (* number of soft errors on disk       *)
  184.     id_UnitNumber    : LONGINT ; (* Which unit disk is (was) mounted on *)
  185.     id_DiskState     : LONGINT ; (* See defines below         *)
  186.     id_NumBlocks     : LONGINT ; (* Number of blocks on disk    *)
  187.     id_NumBlocksUsed : LONGINT ; (* Number of block in use      *)
  188.     id_BytesPerBlock : LONGINT ;
  189.     id_DiskType         : LONGINT ; (* Disk Type code            *)
  190.     id_VolumeNode    : DeviceListPtr ;
  191.                      (* BCPL pointer to volume node *)
  192.     id_InUse         : LONGINT ; (* Flag, zero if not in use    *)
  193.   END ; (* InfoData *)
  194.  
  195. (* ID stands for InfoData *)
  196. (* Disk states *)
  197. CONST
  198.   ID_WRITE_PROTECTED = 80 ; (* Disk is write protected          *)
  199.   ID_VALIDATING         = 81 ; (* Disk is currently being validated *)
  200.   ID_VALIDATED         = 82 ; (* Disk is consistent and writeable  *)
  201.  
  202. (* Disk types *)
  203. (* ID_INTER_* use international case comparison routines for hashing *)
  204. (* Any other new filesystems should also, if possible.             *)
  205.  
  206.   ID_NO_DISK_PRESENT  = -1 ;
  207.   ID_UNREADABLE_DISK  = 042414400H ; (* 'BAD\0' *)
  208.   ID_DOS_DISK          = 0444F5300H ; (* 'DOS\0' *)
  209.   ID_FFS_DISK          = 0444F5301H ; (* 'DOS\1' *)
  210.   ID_INTER_DOS_DISK   = 0444F5302H ; (* 'DOS\2' *)
  211.   ID_INTER_FFS_DISK   = 0444F5303H ; (* 'DOS\3' *)
  212.   ID_FASTDIR_DOS_DISK = 0444F5304H ; (* 'DOS\4' *)
  213.   ID_FASTDIR_FFS_DISK = 0444F5305H ; (* 'DOS\5' *)
  214.   ID_NOT_REALLY_DOS   = 04E444F53H ; (* 'NDOS'  *)
  215.   ID_KICKSTART_DISK   = 04B49434BH ; (* 'KICK'  *)
  216.   ID_MSDOS_DISK          = 04D534400H ; (* 'MSD\0' *)
  217.  
  218. (* Errors from IoErr(), etc. *)
  219.   ERROR_NO_FREE_STORE          = 103 ;
  220.   ERROR_TASK_TABLE_FULL          = 105 ;
  221.   ERROR_BAD_TEMPLATE          = 114 ;
  222.   ERROR_BAD_NUMBER          = 115 ;
  223.   ERROR_REQUIRED_ARG_MISSING      = 116 ;
  224.   ERROR_KEY_NEEDS_ARG          = 117 ;
  225.   ERROR_TOO_MANY_ARGS          = 118 ;
  226.   ERROR_UNMATCHED_QUOTES      = 119 ;
  227.   ERROR_LINE_TOO_LONG          = 120 ;
  228.   ERROR_FILE_NOT_OBJECT          = 121 ;
  229.   ERROR_INVALID_RESIDENT_LIBRARY  = 122 ;
  230.   ERROR_NO_DEFAULT_DIR          = 201 ;
  231.   ERROR_OBJECT_IN_USE          = 202 ;
  232.   ERROR_OBJECT_EXISTS          = 203 ;
  233.   ERROR_DIR_NOT_FOUND          = 204 ;
  234.   ERROR_OBJECT_NOT_FOUND      = 205 ;
  235.   ERROR_BAD_STREAM_NAME          = 206 ;
  236.   ERROR_OBJECT_TOO_LARGE      = 207 ;
  237.   ERROR_ACTION_NOT_KNOWN      = 209 ;
  238.   ERROR_INVALID_COMPONENT_NAME      = 210 ;
  239.   ERROR_INVALID_LOCK          = 211 ;
  240.   ERROR_OBJECT_WRONG_TYPE      = 212 ;
  241.   ERROR_DISK_NOT_VALIDATED      = 213 ;
  242.   ERROR_DISK_WRITE_PROTECTED      = 214 ;
  243.   ERROR_RENAME_ACROSS_DEVICES      = 215 ;
  244.   ERROR_DIRECTORY_NOT_EMPTY      = 216 ;
  245.   ERROR_TOO_MANY_LEVELS          = 217 ;
  246.   ERROR_DEVICE_NOT_MOUNTED      = 218 ;
  247.   ERROR_SEEK_ERROR          = 219 ;
  248.   ERROR_COMMENT_TOO_BIG          = 220 ;
  249.   ERROR_DISK_FULL          = 221 ;
  250.   ERROR_DELETE_PROTECTED      = 222 ;
  251.   ERROR_WRITE_PROTECTED          = 223 ;
  252.   ERROR_READ_PROTECTED          = 224 ;
  253.   ERROR_NOT_A_DOS_DISK          = 225 ;
  254.   ERROR_NO_DISK              = 226 ;
  255.   ERROR_NO_MORE_ENTRIES          = 232 ;
  256.  
  257. (* added for 1.4 *)
  258.  
  259.   ERROR_IS_SOFT_LINK          = 233 ;
  260.   ERROR_OBJECT_LINKED          = 234 ;
  261.   ERROR_BAD_HUNK          = 235 ;
  262.   ERROR_NOT_IMPLEMENTED          = 236 ;
  263.   ERROR_RECORD_NOT_LOCKED      = 240 ;
  264.   ERROR_LOCK_COLLISION          = 241 ;
  265.   ERROR_LOCK_TIMEOUT          = 242 ;
  266.   ERROR_UNLOCK_ERROR          = 243 ;
  267.  
  268. (* error codes 303-305 are defined in dosasl.h *)
  269.  
  270. (* These are the return codes used by convention by AmigaDOS commands *)
  271. (* See FAILAT and IF for relvance to EXECUTE files              *)
  272.   RETURN_OK    = 0  ; (* No problems, success        *)
  273.   RETURN_WARN  = 5  ; (* A warning only            *)
  274.   RETURN_ERROR = 10 ; (* Something wrong        *)
  275.   RETURN_FAIL  = 20 ; (* Complete or severe failure *)
  276.  
  277. (* Bit numbers that signal you that a user has issued a break *)
  278.   SIGBREAKB_CTRL_C = 12 ;
  279.   SIGBREAKB_CTRL_D = 13 ;
  280.   SIGBREAKB_CTRL_E = 14 ;
  281.   SIGBREAKB_CTRL_F = 15 ;
  282.  
  283. (* Bit fields that signal you that a user has issued a break              *)
  284. (* for example:IF SIGBREAKF_CTRL_C IN SetSignal({},{}) THEN cleanup_and_exit()*)
  285.   SIGBREAKF_CTRL_C = {SIGBREAKB_CTRL_C} ;
  286.   SIGBREAKF_CTRL_D = {SIGBREAKB_CTRL_D} ;
  287.   SIGBREAKF_CTRL_E = {SIGBREAKB_CTRL_E} ;
  288.   SIGBREAKF_CTRL_F = {SIGBREAKB_CTRL_F} ;
  289.  
  290. (* Values returned by SameLock() *)
  291.   LOCK_DIFFERENT    = -1 ;
  292.   LOCK_SAME        =  0 ;
  293.   LOCK_SAME_VOLUME    =  1 ;    (* locks are on same volume *)
  294.   LOCK_SAME_HANDLER    = LOCK_SAME_VOLUME ;
  295. (* LOCK_SAME_HANDLER was a misleading name, def kept for src compatibility *)
  296.  
  297. (* types for ChangeMode() *)
  298.   CHANGE_LOCK    = 0 ;
  299.   CHANGE_FH    = 1 ;
  300.  
  301. (* Values for MakeLink() *)
  302.   LINK_HARD    = 0 ;
  303.   LINK_SOFT    = 1 ;  (* softlinks are not fully supported yet *)
  304.  
  305. (* values returned by ReadItem *)
  306.   ITEM_EQUAL    = -2 ; (* "=" Symbol         *)
  307.   ITEM_ERROR    = -1 ; (* error             *)
  308.   ITEM_NOTHING    =  0 ; (* *N, ;, endstreamch *)
  309.   ITEM_UNQUOTED    =  1 ; (* unquoted item         *)
  310.   ITEM_QUOTED    =  2 ; (* quoted item         *)
  311.  
  312. (* types for AllocDosObject/FreeDosObject *)
  313.   DOS_FILEHANDLE   = 0 ; (* few people should use this        *)
  314.   DOS_EXALLCONTROL = 1 ; (* Must be used to allocate this!  *)
  315.   DOS_FIB       = 2 ; (* useful                *)
  316.   DOS_STDPKT       = 3 ; (* for doing packet-level I/O        *)
  317.   DOS_CLI       = 4 ; (* for shell-writers, etc         *)
  318.   DOS_RDARGS       = 5 ; (* for ReadArgs if you pass it in  *)
  319.  
  320. (* All DOS processes have this structure                   *)
  321. (* Create and Device Proc returns pointer to the MsgPort in this structure *)
  322. (* dev_proc = ( struct Process * )(DeviceProc(..) - sizeof(struct Task));  *)
  323.  
  324. TYPE
  325.   Process = RECORD
  326.     pr_Task          : Task     ;
  327.     pr_MsgPort          : MsgPort  ; (* This is BPTR address from DOS functions *)
  328.     pr_Pad          : INTEGER  ; (* Remaining variables on 4 byte boundaries*)
  329.     pr_SegList          : BADDRESS ; (* Array of seg lists used by this process *)
  330.     pr_StackSize      : LONGINT  ; (* Size of process stack in bytes          *)
  331.     pr_GlobVec          : ADDRESS  ; (* Global vector for this process (BCPL)   *)
  332.     pr_TaskNum          : LONGINT  ; (* CLI task number of zero if not a CLI    *)
  333.     pr_StackBase      : BADDRESS ; (* Ptr to high memory end of process stack *)
  334.     pr_Result2          : LONGINT  ; (* Value of secondary result from last call*)
  335.     pr_CurrentDir     : FileLockPtr ;
  336.                        (* Lock associated with current directory  *)
  337.     pr_CIS,pr_COS     : FileHandlePtr ;
  338.                        (* Current CLI Input/OutPut Streams          *)
  339.     pr_ConsoleTask    : ADDRESS  ; (* Console handler process for curr. window*)
  340.     pr_FileSystemTask : ADDRESS  ; (* File handler process for current drive  *)
  341.     pr_CLI          : CommandLineInterfacePtr ;
  342.                        (* pointer to CommandLineInterface          *)
  343.     pr_ReturnAddr     : ADDRESS  ; (* pointer to previous stack frame          *)
  344.     pr_PktWait          : ADDRESS  ; (* Function to be called when awaiting msg *)
  345.     pr_WindowPtr      : ADDRESS  ; (* Window for error printing              *)
  346.  
  347.     (* following definitions are new with 2.0 *)
  348.     pr_HomeDir        : FileLockPtr ;
  349.                        (* Home directory of executing program     *)
  350.     pr_Flags          : LONGSET  ; (* flags telling dos about process          *)
  351.     pr_ExitCode       : PROC     ; (* code to call on exit of program or NULL *)
  352.     pr_ExitData       : LONGINT  ; (* Passed as an argument to pr_ExitCode.   *)
  353.     pr_Arguments      : STRING   ; (* Arguments passed to the process at start*)
  354.     pr_LocalVars      : MinList  ; (* Local environment variables          *)
  355.     pr_ShellPrivate   : LONGINT  ; (* for the use of the current shell          *)
  356.     pr_CES          : FileHandlePtr ;
  357.                        (* Error stream - if NULL, use pr_COS      *)
  358.   END ;  (* Process *)
  359.  
  360. (* Flags for pr_Flags *)
  361.  
  362. CONST
  363.   PRB_FREESEGLIST =  0  ; PRF_FREESEGLIST = {0} ;
  364.   PRB_FREECURRDIR =  1  ; PRF_FREECURRDIR = {1} ;
  365.   PRB_FREECLI      =  2  ; PRF_FREECLI      = {2} ;
  366.   PRB_CLOSEINPUT  =  3  ; PRF_CLOSEINPUT  = {3} ;
  367.   PRB_CLOSEOUTPUT =  4  ; PRF_CLOSEOUTPUT = {4} ;
  368.   PRB_FREEARGS      =  5  ; PRF_FREEARGS      = {5} ;
  369.  
  370. (* The long word address (BPTR) of this structure is returned by    *)
  371. (* Open() and other routines that return a file.  You need only worry    *)
  372. (* about this struct to do async io's via PutMsg() instead of        *)
  373. (* standard file system calls                        *)
  374.  
  375. TYPE
  376.   FileHandle = RECORD
  377.     fh_Link : MessagePtr ; (* EXEC message              *)
  378.     fh_Port : MsgPortPtr ; (* Reply port for the packet          *)
  379.     fh_Type : MsgPortPtr ; (* Port to do PutMsg() to          *)
  380.                (* Address is negative if a plain file *)
  381.     fh_Buf : LONGINT ;
  382.     fh_Pos : LONGINT ;
  383.     fh_End : LONGINT ;
  384.     CASE :INTEGER OF
  385.     |0:fh_Funcs : LONGINT
  386.     |1:fh_Func1 : LONGINT
  387.     END ;
  388.     fh_Func2 : LONGINT ;
  389.     fh_Func3 : LONGINT ;
  390.     CASE :INTEGER OF
  391.     |0:fh_Args : LONGINT
  392.     |1:fh_Arg1 : LONGINT
  393.     END ;
  394.     fh_Arg2 : LONGINT
  395.   END ; (* FileHandle *)
  396.  
  397. (* This is the extension to EXEC Messages used by DOS *)
  398.  
  399. TYPE
  400.   DosPacket = RECORD
  401.     dp_Link : MessagePtr ; (* EXEC message               *)
  402.     dp_Port : MsgPortPtr ; (* Reply port for the packet    *)
  403.                (* Must be filled in each send. *)
  404.     CASE :INTEGER OF
  405.     |0:
  406.       dp_Type : LONGINT ;     (* See ACTION_... below and              *)
  407.                  (* 'R' means Read, 'W' means Write to the    *)
  408.                  (* file system                   *)
  409.       dp_Res1 : LONGINT ;     (* For file system calls this is the result  *)
  410.                  (* that would have been returned by the      *)
  411.                  (* function, e.g. Write ('W') returns actual *)
  412.                  (* length written                  *)
  413.       dp_Res2 : LONGINT ;     (* For file system calls this is what would  *)
  414.                  (* have been returned by IoErr()          *)
  415.       dp_Arg1 : LONGINT ;
  416.     |1: (*  Device packets common equivalents *)
  417.       dp_Action  : LONGINT ;
  418.       dp_Status  : LONGINT ;
  419.       dp_Status2 : LONGINT ;
  420.       dp_BufAddr : LONGINT ;
  421.     END ;
  422.  
  423.     dp_Arg2 : LONGINT ;
  424.     dp_Arg3 : LONGINT ;
  425.     dp_Arg4 : LONGINT ;
  426.     dp_Arg5 : LONGINT ;
  427.     dp_Arg6 : LONGINT ;
  428.     dp_Arg7 : LONGINT ;
  429.   END ; (* DosPacket *)
  430.  
  431. (* A Packet does not require the Message to be before it in memory, but *)
  432. (* for convenience it is useful to associate the two.            *)
  433. (* Also see the function init_std_pkt for initializing this structure   *)
  434.  
  435.   StandardPacket = RECORD
  436.     sp_Msg : Message   ;
  437.     sp_Pkt : DosPacket ;
  438.   END ; (* StandardPacket *)
  439.  
  440. (* Packet types *)
  441. CONST
  442.   ACTION_NIL        = 0  ;
  443.   ACTION_STARTUP    = 0  ;
  444.   ACTION_GET_BLOCK    = 2  ;    (* OBSOLETE *)
  445.   ACTION_SET_MAP    = 4  ;
  446.   ACTION_DIE        = 5  ;
  447.   ACTION_EVENT        = 6  ;
  448.   ACTION_CURRENT_VOLUME    = 7  ;
  449.   ACTION_LOCATE_OBJECT    = 8  ;
  450.   ACTION_RENAME_DISK    = 9  ;
  451.   ACTION_WRITE        ='W' ;
  452.   ACTION_READ        ='R' ;
  453.   ACTION_FREE_LOCK    = 15 ;
  454.   ACTION_DELETE_OBJECT    = 16 ;
  455.   ACTION_RENAME_OBJECT    = 17 ;
  456.   ACTION_MORE_CACHE    = 18 ;
  457.   ACTION_COPY_DIR    = 19 ;
  458.   ACTION_WAIT_CHAR    = 20 ;
  459.   ACTION_SET_PROTECT    = 21 ;
  460.   ACTION_CREATE_DIR    = 22 ;
  461.   ACTION_EXAMINE_OBJECT    = 23 ;
  462.   ACTION_EXAMINE_NEXT    = 24 ;
  463.   ACTION_DISK_INFO    = 25 ;
  464.   ACTION_INFO        = 26 ;
  465.   ACTION_FLUSH        = 27 ;
  466.   ACTION_SET_COMMENT    = 28 ;
  467.   ACTION_PARENT        = 29 ;
  468.   ACTION_TIMER        = 30 ;
  469.   ACTION_INHIBIT    = 31 ;
  470.   ACTION_DISK_TYPE    = 32 ;
  471.   ACTION_DISK_CHANGE    = 33 ;
  472.   ACTION_SET_DATE    = 34 ;
  473.  
  474.   ACTION_SCREEN_MODE    = 994  ;
  475.  
  476.   ACTION_READ_RETURN    = 1001 ;
  477.   ACTION_WRITE_RETURN    = 1002 ;
  478.   ACTION_SEEK        = 1008 ;
  479.   ACTION_FINDUPDATE    = 1004 ;
  480.   ACTION_FINDINPUT    = 1005 ;
  481.   ACTION_FINDOUTPUT    = 1006 ;
  482.   ACTION_END        = 1007 ;
  483.   ACTION_SET_FILE_SIZE    = 1022 ; (* fast file system only in 1.3 *)
  484.   ACTION_WRITE_PROTECT    = 1023 ; (* fast file system only in 1.3 *)
  485.  
  486.   (* new 2.0 packets *)
  487.  
  488.   ACTION_SAME_LOCK    = 40   ;
  489.   ACTION_CHANGE_SIGNAL    = 995  ;
  490.   ACTION_FORMAT        = 1020 ;
  491.   ACTION_MAKE_LINK    = 1021 ;
  492.  
  493.   ACTION_READ_LINK    = 1024 ;
  494.   ACTION_FH_FROM_LOCK    = 1026 ;
  495.   ACTION_IS_FILESYSTEM    = 1027 ;
  496.   ACTION_CHANGE_MODE    = 1028 ;
  497.  
  498.   ACTION_COPY_DIR_FH    = 1030 ;
  499.   ACTION_PARENT_FH    = 1031 ;
  500.   ACTION_EXAMINE_ALL    = 1033 ;
  501.   ACTION_EXAMINE_FH    = 1034 ;
  502.  
  503.   ACTION_LOCK_RECORD    = 2008 ;
  504.   ACTION_FREE_RECORD    = 2009 ;
  505.  
  506.   ACTION_ADD_NOTIFY    = 4097 ;
  507.   ACTION_REMOVE_NOTIFY    = 4098 ;
  508.  
  509.   (* Added in V39: *)
  510.  
  511.   ACTION_EXAMINE_ALL_END = 1035 ;
  512.   ACTION_SET_OWNER     = 1036 ;
  513.  
  514. (* Tell a file system to serialize the current volume. This is typically     *)
  515. (* done by changing the creation date of the disk. This packet does not take *)
  516. (* any arguments.  NOTE: be prepared to handle failure of this packet for    *)
  517. (* V37 ROM filesystems.                                 *)
  518.  
  519. CONST
  520.   ACTION_SERIALIZE_DISK    = 4200 ;
  521.  
  522.  (* A structure for holding error messages - stored as array with error == 0 *)
  523.  (* for the last entry.                                 *)
  524.  
  525. TYPE
  526.   ErrorString = RECORD
  527.     estr_Nums    : ADDRESS ;
  528.     estr_Strings : STRING  ;
  529.   END ;
  530.  
  531.  
  532.  (* DOS library node structure.                        *)
  533.  (* This is the data at positive offsets from the library node.        *)
  534.  (* Negative offsets from the node is the jump table to DOS functions    *)
  535.  (* node = (struct DosLibrary * ) OpenLibrary( "dos.library" .. )    *)
  536.  
  537.   DosLibrary = RECORD
  538.     dl_lib  : Library ;
  539.     dl_Root : RootNodePtr ; (* Pointer to RootNode, described below   *)
  540.     dl_GV   : ADDRESS ;        (* Pointer to BCPL global vector          *)
  541.     dl_A2   : LONGINT ;        (* BCPL standard register values          *)
  542.     dl_A5   : LONGINT ;
  543.     dl_A6   : LONGINT ;
  544.     dl_Errors  : ErrorStringPtr ;   (* PRIVATE pointer to array of error msgs *)
  545.     dl_TimeReq : ADDRESS ;        (* PRIVATE pointer to timer request          *)
  546.     dl_UtilityBase   : LibraryPtr ; (* PRIVATE ptr to utility library          *)
  547.     dl_IntuitionBase : LibraryPtr ; (* PRIVATE ptr to intuition library          *)
  548.   END ; (* DosLibrary *)
  549.  
  550. TYPE
  551.   RootNode = RECORD
  552.     rn_TaskArray : BCPL POINTER TO RECORD
  553.                   maxCLI : LONGINT ; (* [0] is max number of CLI's *)
  554.               pids   : ARRAY [1..100000] OF MsgPortPtr ;
  555.             END ; (* [1] is APTR to process id of CLI 1    *)
  556.                   (* [n] is APTR to process id of CLI n     *)
  557.     rn_ConsoleSegment : BADDRESS  ; (* SegList for the CLI              *)
  558.     rn_Time          : DateStampRec;(* Current time                  *)
  559.     rn_RestartSeg     : BADDRESS  ; (* SegList for the disk validator process *)
  560.     rn_Info          : DosInfoPtr; (* Pointer to the Info structure          *)
  561.     rn_FileHandlerSegment : BADDRESS ; (* segment for a file handler          *)
  562.     rn_CliList      : MinList ; (* new list of all CLI processes          *)
  563.                     (* the first cpl_Array is also rn_TaskArray   *)
  564.     rn_BootProc     : MsgPortPtr ; (* private ptr to msgport of boot fs          *)
  565.     rn_ShellSegment : BADDRESS   ; (* seglist for Shell (for NewShell)          *)
  566.     rn_Flags        : LONGSET    ; (* dos flags *)
  567.   END ;  (* RootNode *)
  568.  
  569. CONST
  570.   RNB_WILDSTAR = 24 ; RNF_WILDSTAR = {24} ;
  571.  
  572.   RNB_PRIVATE1 = 1 ;  RNF_PRIVATE1 = {1} ; (* private for dos *)
  573.  
  574. (* ONLY to be allocated by DOS! *)
  575.  
  576. TYPE
  577.   CliProcList = RECORD
  578.     cpl_Node  : MinNode ;
  579.     cpl_First : LONGINT ; (* number of first entry in array *)
  580.     cpl_Array : POINTER TO ARRAY OF MsgPortPtr ;
  581.                 (* [0] is max number of CLI's in this entry (n)   *)
  582.                 (* [1] is CPTR to process id of CLI cpl_First     *)
  583.                 (* [n] is CPTR to process id of CLI cpl_First+n-1 *)
  584.   END ;
  585.  
  586. TYPE
  587.   DosInfo = RECORD
  588.     CASE :INTEGER OF
  589.     |0:di_McName  : BADDRESS ; (* PRIVATE: system resident module list        *)
  590.     |1:di_ResList : BADDRESS ;
  591.     END ;
  592.     di_DevInfo    : DevInfoPtr;(* Device List                    *)
  593.     di_Devices    : BADDRESS ; (* Currently zero                *)
  594.     di_Handlers   : BADDRESS ; (* Currently zero                *)
  595.     di_NetHand    : ADDRESS  ; (* Network handler processid; currently zero *)
  596.     di_DevLock    : SignalSemaphore ; (* do NOT access directly! *)
  597.     di_EntryLock  : SignalSemaphore ; (* do NOT access directly! *)
  598.     di_DeleteLock : SignalSemaphore ; (* do NOT access directly! *)
  599.   END ;  (* DosInfo *)
  600.  
  601. (* structure for the Dos resident list.  Do NOT allocate these, use      *)
  602. (* AddSegment(), and heed the warnings in the autodocs!              *)
  603.  
  604.   Segment = RECORD
  605.     seg_Next : BADDRESS ;
  606.     seg_UC   : LONGINT  ;
  607.     seg_Seg  : BADDRESS ;
  608.     seg_Name : ARRAY [0..3] OF CHAR ;(* actually the first 4 ch's of BSTR name*)
  609.   END ;
  610.  
  611. CONST
  612.   CMD_SYSTEM   = -1   ;
  613.   CMD_INTERNAL = -2   ;
  614.   CMD_DISABLED = -999 ;
  615.  
  616. (* DOS Processes started from the CLI via RUN or NEWCLI have this additional *)
  617. (* set to data associated with them                         *)
  618.  
  619. TYPE
  620.   CommandLineInterface = RECORD
  621.     cli_Result2        : LONGINT  ; (* Value of IoErr from last command      *)
  622.     cli_SetName        : BSTRING  ; (* Name of current directory          *)
  623.     cli_CommandDir    : BADDRESS ; (* Head of the path locklist          *)
  624.     cli_ReturnCode    : LONGINT  ; (* Return code from last command          *)
  625.     cli_CommandName    : BSTRING  ; (* Name of current command              *)
  626.     cli_FailLevel    : LONGINT  ; (* Fail level (set by FAILAT)          *)
  627.     cli_Prompt        : BSTRING  ; (* Current prompt (set by PROMPT)          *)
  628.     cli_StandardInput    : FileHandlePtr ;
  629.                          (* Default (terminal) CLI input          *)
  630.     cli_CurrentInput    : FileHandlePtr ;
  631.                          (* Current CLI input              *)
  632.     cli_CommandFile    : BSTRING  ; (* Name of EXECUTE command file          *)
  633.     cli_Interactive    : LONGINT  ; (* Boolean; True if prompts required     *)
  634.     cli_Background    : LONGINT  ; (* Boolean; True if CLI created by RUN   *)
  635.     cli_CurrentOutput    : FileHandlePtr ;
  636.                          (* Current CLI output              *)
  637.     cli_DefaultStack    : LONGINT  ; (* Stack size to be obtained in longwords*)
  638.     cli_StandardOutput    : FileHandlePtr ;
  639.                          (* Default (terminal) CLI output          *)
  640.     cli_Module        : BADDRESS ; (* SegList of currently loaded command   *)
  641.   END ;  (* CommandLineInterface *)
  642.  
  643.  
  644.  (* This structure can take on different values depending on whether it is  *)
  645.  (* a device, an assigned directory, or a volume.  Below is the structure   *)
  646.  (* reflecting volumes only.  Following that is the structure representing  *)
  647.  (* only devices. Following that is the unioned structure representing all  *)
  648.  (* the values                                    *)
  649.  
  650.  (* structure representing a volume *)
  651.  
  652. TYPE
  653.   DeviceList = RECORD
  654.     dl_Next      : DeviceListPtr ; (* bptr to next device list         *)
  655.     dl_Type      : LONGINT       ; (* see DLT below             *)
  656.     dl_Task      : MsgPortPtr      ; (* ptr to handler task         *)
  657.     dl_Lock      : FileLockPtr      ; (* not for volumes             *)
  658.     dl_VolumeDate : DateStampRec  ; (* creation date             *)
  659.     dl_LockList   : FileLockPtr   ; (* outstanding locks         *)
  660.     dl_DiskType   : LONGINT      ; (* 'DOS', etc             *)
  661.     dl_unused     : LONGINT      ;
  662.     dl_Name       : BSTRING      ; (* bptr to bcpl name         *)
  663.   END ;
  664.  
  665. (* device structure *)
  666.  
  667. TYPE
  668.   DevInfo = RECORD
  669.     dvi_Next      : DevInfoPtr    ;
  670.     dvi_Type      : LONGINT    ;
  671.     dvi_Task      : ADDRESS    ;
  672.     dvi_Lock      : FileLockPtr ;
  673.     dvi_Handler      : BSTRING  ;
  674.     dvi_StackSize : LONGINT  ;
  675.     dvi_Priority  : LONGINT  ;
  676.     dvi_Startup      : LONGINT  ;
  677.     dvi_SegList      : BADDRESS ;
  678.     dvi_GlobVec   : BADDRESS ;
  679.     dvi_Name      : BSTRING  ;
  680.   END ;
  681.  
  682. (* combined structure for devices, assigned directories, volumes *)
  683.  
  684. TYPE
  685.   DosList = RECORD
  686.     dol_Next : DosListPtr  ; (* bptr to next device on list *)
  687.     dol_Type : LONGINT     ; (* see DLT below            *)
  688.     dol_Task : MsgPortPtr  ; (* ptr to handler task        *)
  689.     dol_Lock : FileLockPtr ;
  690.     CASE :INTEGER OF
  691.     |0:
  692.     dol_misc :
  693.     RECORD
  694.       CASE :INTEGER OF
  695.       |0: dol_handler :
  696.        RECORD
  697.      dol_Handler   : BSTRING  ; (* file name to load if seglist is null   *)
  698.      dol_StackSize : LONGINT  ; (* stacksize to use when starting process *)
  699.      dol_Priority  : LONGINT  ; (* task priority when starting process    *)
  700.      dol_Startup   : LONGINT  ; (* startup msg:FileSysStartupMsg for disks*)
  701.      dol_SegList   : BADDRESS ; (* already loaded code for new task          *)
  702.      dol_GlobVec   : BADDRESS ; (* BCPL global vector to use when starting*)
  703.                     (* a process. -1 indicates a C/Assembler  *)
  704.                     (* program.                      *)
  705.       END ;
  706.       |1: dol_volume :
  707.     RECORD
  708.       dol_VolumeDate : DateStampRec ; (* creation date     *)
  709.       dol_LockList   : FileLockPtr ;  (* outstanding locks *)
  710.       dol_DiskType   : LONGINT ;      (* 'DOS', etc           *)
  711.         END ;
  712.       |2: dol_assign :
  713.     RECORD
  714.       dol_AssignName : STRING ;  (* name for non-or-late-binding assign   *)
  715.       dol_List : AssignListPtr ; (* for multi-directory assigns (regular) *)
  716.         END ;
  717.       END ;
  718.     END ;
  719.     |1:
  720.       CASE :INTEGER OF
  721.       |0:
  722.     dol_Handler   : BSTRING  ;
  723.     dol_StackSize : LONGINT  ;
  724.     dol_Priority  : LONGINT  ;
  725.     dol_Startup   : LONGINT  ;
  726.     dol_SegList   : BADDRESS ;
  727.     dol_GlobVec   : BADDRESS ;
  728.       |1:
  729.     dol_VolumeDate : DateStampRec;
  730.     dol_LockList   : FileLockPtr ;
  731.     dol_DiskType   : LONGINT     ;
  732.       |2:
  733.           dol_AssignName : STRING  ;
  734.     dol_List : AssignListPtr ;
  735.       END ;
  736.     END ;
  737.     dol_Name : BSTRING ; (* bptr to bcpl name *)
  738.   END ;
  739.  
  740. (* structure used for multi-directory assigns. AllocVec()ed. *)
  741.  
  742. TYPE
  743.   AssignList = RECORD
  744.     al_Next : AssignListPtr ;
  745.     al_Lock : FileLockPtr ;
  746.   END ;
  747.  
  748. (* definitions for dl_Type *)
  749.  
  750. CONST
  751.   DLT_DEVICE      = 0 ;
  752.   DLT_DIRECTORY      = 1 ;    (* assign         *)
  753.   DLT_VOLUME      = 2 ;
  754.   DLT_LATE      = 3 ;    (* late-binding assign   *)
  755.   DLT_NONBINDING  = 4 ;    (* non-binding assign    *)
  756.   DLT_PRIVATE      = -1;    (* for internal use only *)
  757.  
  758. (* structure return by GetDeviceProc() *)
  759.  
  760. TYPE
  761.   DevProc = RECORD
  762.     dvp_Port    : MsgPortPtr ;
  763.     dvp_Lock    : FileLockPtr;
  764.     dvp_Flags   : LONGSET    ;
  765.     dvp_DevNode : LONGWORD   ;    (* DON'T TOUCH OR USE! *)
  766.   END ;
  767.  
  768. (* definitions for dvp_Flags *)
  769. CONST
  770.   DVPB_UNLOCK    = 0 ; DVPF_UNLOCK    = {DVPB_UNLOCK} ;
  771.   DVPB_ASSIGN    = 1 ; DVPF_ASSIGN    = {DVPB_ASSIGN} ;
  772.  
  773. (* Flags to be passed to LockDosList(), etc *)
  774.   LDB_DEVICES    = 2 ; LDF_DEVICES    = {LDB_DEVICES} ;
  775.   LDB_VOLUMES    = 3 ; LDF_VOLUMES    = {LDB_VOLUMES} ;
  776.   LDB_ASSIGNS    = 4 ; LDF_ASSIGNS    = {LDB_ASSIGNS} ;
  777.   LDB_ENTRY    = 5 ; LDF_ENTRY        = {LDB_ENTRY} ;
  778.   LDB_DELETE    = 6 ; LDF_DELETE    = {LDB_DELETE} ;
  779.  
  780. (* you MUST specify one of LDF_READ or LDF_WRITE *)
  781.   LDB_READ    = 0 ; LDF_READ    = {LDB_READ} ;
  782.   LDB_WRITE    = 1 ; LDF_WRITE    = {LDB_WRITE} ;
  783.  
  784. (* actually all but LDF_ENTRY (which is used for internal locking) *)
  785.   LDF_ALL    = (LDF_DEVICES+LDF_VOLUMES+LDF_ASSIGNS) ;
  786.  
  787. (* a lock structure, as returned by Lock() or DupLock() *)
  788.  
  789. TYPE
  790.   FileLock = RECORD
  791.     fl_Link   : FileLockPtr; (* bcpl pointer to next lock     *)
  792.     fl_Key    : LONGINT    ; (* disk block number         *)
  793.     fl_Access : LONGINT    ; (* exclusive or shared         *)
  794.     fl_Task   : MsgPortPtr ; (* handler task's port         *)
  795.     fl_Volume : DosListPtr ; (* bptr to DLT_VOLUME DosList entry *)
  796.   END ;
  797.  
  798. (* error report types for ErrorReport() *)
  799.  
  800. CONST
  801.   REPORT_STREAM    = 0 ; (* a stream          *)
  802.   REPORT_TASK    = 1 ; (* a process - unused   *)
  803.   REPORT_LOCK    = 2 ; (* a lock              *)
  804.   REPORT_VOLUME    = 3 ; (* a volume node          *)
  805.   REPORT_INSERT    = 4 ; (* please insert volume *)
  806.  
  807. (* Special error codes for ErrorReport() *)
  808.  
  809.   ABORT_DISK_ERROR = 296 ; (* Read/write error      *)
  810.   ABORT_BUSY       = 288 ; (* You MUST replace... *)
  811.  
  812. (* types for initial packets to shells from run/newcli/execute/system.    *)
  813. (* For shell-writers only                        *)
  814.  
  815.   RUN_EXECUTE        = -1 ;
  816.   RUN_SYSTEM        = -2 ;
  817.   RUN_SYSTEM_ASYNCH = -3 ;
  818.  
  819. (* Types for fib_DirEntryType.    NOTE that both USERDIR and ROOT are     *)
  820. (* directories, and that directory/file checks should use <0 and >=0.     *)
  821. (* This is not necessarily exhaustive!    Some handlers may use other     *)
  822. (* values as needed, though <0 and >=0 should remain as supported as     *)
  823. (* possible.                                 *)
  824.  
  825.   ST_ROOT    =  1 ;
  826.   ST_USERDIR    =  2 ;
  827.   ST_SOFTLINK    =  3 ; (* looks like dir, but may point to a file! *)
  828.   ST_LINKDIR    =  4 ; (* hard link to dir               *)
  829.   ST_FILE    = -3 ; (* must be negative for FIB!           *)
  830.   ST_LINKFILE    = -4 ; (* hard link to file               *)
  831.   ST_PIPEFILE    = -5 ; (* for pipes that support ExamineFH       *)
  832.  
  833.  (*    Data structures and equates used by the V1.4 DOS functions    *)
  834.  (* StrtoDate() and DatetoStr()                        *)
  835.  
  836. (* --------- String/Date structures etc ---------- *)
  837.  
  838. TYPE
  839.   DateTime = RECORD
  840.     dat_Stamp   : DateStampRec ; (* DOS DateStamp            *)
  841.     dat_Format  : SHORTCARD    ; (* controls appearance of dat_StrDate  *)
  842.     dat_Flags   : SHORTSET     ; (* see BITDEF's below                *)
  843.     dat_StrDay  : STRING       ; (* day of the week string        *)
  844.     dat_StrDate : STRING       ; (* date string                *)
  845.     dat_StrTime : STRING       ; (* time string                *)
  846.   END ;
  847.  
  848. (* You need this much room for each of the DateTime strings: *)
  849. CONST
  850.   LEN_DATSTRING    = 16 ;
  851.  
  852. (* flags for dat_Flags *)
  853.  
  854. CONST
  855.   DTB_SUBST  = 0 ; DTF_SUBST  = {0} ; (* substitute Today, Tomorrow, etc.*)
  856.   DTB_FUTURE = 1 ; DTF_FUTURE = {1} ; (* day of the week is in future     *)
  857.  
  858. (* date format values *)
  859.  
  860. CONST
  861.   FORMAT_DOS = 0 ; (* dd-mmm-yy *)
  862.   FORMAT_INT = 1 ; (* yy-mm-dd  *)
  863.   FORMAT_USA = 2 ; (* mm-dd-yy  *)
  864.   FORMAT_CDN = 3 ; (* dd-mm-yy  *)
  865.   FORMAT_MAX = FORMAT_CDN ;
  866.  
  867. (*----------------------------------------------------------------------------*)
  868. (*-------------------------- PATTERN MATCHING --------------------------------*)
  869. (*----------------------------------------------------------------------------*)
  870. (* structure expected by MatchFirst, MatchNext.                      *)
  871. (* Allocate this structure and initialize it as follows:              *)
  872. (*                                          *)
  873. (* Set ap_BreakBits to the signal bits (CDEF) that you want to take a          *)
  874. (* break on, or NULL, if you don't want to convenience the user.          *)
  875. (*                                          *)
  876. (* If you want to have the FULL PATH NAME of the files you found,          *)
  877. (* allocate a buffer at the END of this structure, and put the size of          *)
  878. (* it into ap_Strlen.  If you don't want the full path name, make sure          *)
  879. (* you set ap_Strlen to zero.  In this case, the name of the file, and stats  *)
  880. (* are available in the ap_Info, as per usual.                      *)
  881. (*                                          *)
  882. (* Then call MatchFirst() and then afterwards,MatchNext() with this structure.*)
  883. (* You should check the return value each time (see below) and take the          *)
  884. (* appropriate action, ultimately calling MatchEnd() when there are          *)
  885. (* no more files and you are done.  You can tell when you are done by          *)
  886. (* checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.          *)
  887.  
  888. TYPE
  889.   AnchorPath  = RECORD
  890.     CASE :INTEGER OF
  891.     |0:ap_Base       : AChainPtr ; (* pointer to first anchor              *)
  892.     |1:ap_First       : AChainPtr ;
  893.     END ;
  894.     CASE :INTEGER OF
  895.     |0:ap_Last     : AChainPtr ; (* pointer to last anchor              *)
  896.     |1:ap_Current  : AChainPtr ;
  897.     END ;
  898.     ap_BreakBits   : LONGINT   ; (* Bits we want to break on              *)
  899.     ap_FoundBreak  : LONGINT   ; (* Bits we broke on.Also returns ERROR_BREAK *)
  900.     CASE :INTEGER OF
  901.     |0:ap_Flags    : SHORTSET  ; (* New use for extra word.              *)
  902.        ap_Reserved : SHORTINT  ;
  903.        ap_Strlen   : CARDINAL  ; (* This is what ap_Length used to be          *)
  904.     |1:ap_Length: LONGINT ;     (* Old compatability for LONGWORD ap_Length  *)
  905.     END ;
  906.     ap_Info : FileInfoBlock ;
  907.     ap_Buf  : ARRAY [0..0] OF CHAR ;(* Buffer for path name,allocated by user*)
  908.     (* FIX! *)
  909.   END ;
  910.  
  911.  
  912. CONST
  913.   APB_DOWILD       =  0  ; (* User option ALL                *)
  914.   APF_DOWILD       = {0} ;
  915.  
  916.   APB_ITSWILD       =  1  ; (* Set by MatchFirst, used by MatchNext    *)
  917.   APF_ITSWILD       = {1} ; (* Application can test APB_ITSWILD, too    *)
  918.                (* (means that there's a wildcard        *)
  919.                (* in the pattern after calling        *)
  920.                (* MatchFirst).                *)
  921.  
  922.   APB_DODIR       =  2  ; (* Bit is SET if a DIR node should be    *)
  923.   APF_DODIR       = {2} ; (* entered. Application can RESET this    *)
  924.                (* bit after MatchFirst/MatchNext to AVOID    *)
  925.                (* entering a dir.                *)
  926.  
  927.   APB_DIDDIR       =  3  ; (* Bit is SET for an "expired" dir node.    *)
  928.   APF_DIDDIR       = {3} ;
  929.  
  930.   APB_NOMEMERR       =  4  ; (* Set on memory error            *)
  931.   APF_NOMEMERR       = {4} ;
  932.  
  933.   APB_DODOT       =  5  ; (* If set, allow conversion of '.' to    *)
  934.   APF_DODOT        = {5} ; (* CurrentDir                *)
  935.  
  936.   APB_DirChanged   =  6  ; (* ap_Current->an_Lock changed        *)
  937.   APF_DirChanged   = {6} ; (* since last MatchNext call            *)
  938.  
  939.   APB_FollowHLinks =  7  ; (* follow hardlinks on DODIR - defaults     *)
  940.   APF_FollowHLinks = {7} ; (* to not following hardlinks on a DODIR.    *)
  941.  
  942. TYPE
  943.   AChain = RECORD
  944.     an_Child  : AChainPtr ;
  945.     an_Parent : AChainPtr ;
  946.     an_Lock   : FileLockPtr  ;
  947.     an_Info   : FileInfoBlock ;
  948.     an_Flags  : SHORTSET ;
  949.     an_String : ARRAY [0..0] OF CHAR ;    (* FIX!! *)
  950.   END ;
  951.  
  952. CONST
  953.   DDB_PatternBit  = 0 ; DDF_PatternBit  = {0} ;
  954.   DDB_ExaminedBit = 1 ; DDF_ExaminedBit = {1} ;
  955.   DDB_Completed      = 2 ; DDF_Completed   = {2} ;
  956.   DDB_AllBit      = 3 ; DDF_AllBit      = {3} ;
  957.   DDB_Single      = 4 ; DDF_Single    = {4} ;
  958.  
  959. (* Constants used by wildcard routines, these are the pre-parsed tokens        *)
  960. (* referred to by pattern match.  It is not necessary for you to do        *)
  961. (* anything about these, MatchFirst() MatchNext() handle all these for you. *)
  962.  
  963.   P_ANY        = 080H ; (* Token for '*' or '#?  *)
  964.   P_SINGLE    = 081H ; (* Token for '?' *)
  965.   P_ORSTART    = 082H ; (* Token for '(' *)
  966.   P_ORNEXT    = 083H ; (* Token for '|' *)
  967.   P_OREND    = 084H ; (* Token for ')' *)
  968.   P_NOT        = 085H ; (* Token for '~' *)
  969.   P_NOTEND    = 086H ; (* Token for      *)
  970.   P_NOTCLASS    = 087H ; (* Token for '^' *)
  971.   P_CLASS    = 088H ; (* Token for '[]'*)
  972.   P_REPBEG    = 089H ; (* Token for '[' *)
  973.   P_REPEND    = 08AH ; (* Token for ']' *)
  974.   P_STOP    = 08BH ; (* token to force end of evaluation *)
  975.  
  976. (* Values for an_Status, NOTE: These are the actual bit numbers *)
  977.  
  978.   COMPLEX_BIT    = 1 ; (* Parsing complex pattern *)
  979.   EXAMINE_BIT    = 2 ; (* Searching directory     *)
  980.  
  981. (* Returns from MatchFirst(), MatchNext()                *)
  982. (* You can also get dos error returns, such as ERROR_NO_MORE_ENTRIES,    *)
  983. (* these are in the dos.h file.                        *)
  984.  
  985.   ERROR_BUFFER_OVERFLOW    = 303 ;    (* User or internal buffer overflow *)
  986.   ERROR_BREAK        = 304 ;    (* A break character was received   *)
  987.   ERROR_NOT_EXECUTABLE    = 305 ;    (* A file has E bit cleared        *)
  988.  
  989. (* hunk types *)
  990. CONST
  991.   HUNK_UNIT      = 999  ;
  992.   HUNK_NAME      = 1000 ;
  993.   HUNK_CODE      = 1001 ;
  994.   HUNK_DATA      = 1002 ;
  995.   HUNK_BSS      = 1003 ;
  996.   HUNK_RELOC32      = 1004 ;
  997.   HUNK_ABSRELOC32 = HUNK_RELOC32 ;
  998.   HUNK_RELOC16      = 1005 ;
  999.   HUNK_RELRELOC16 = HUNK_RELOC16 ;
  1000.   HUNK_RELOC8      = 1006 ;
  1001.   HUNK_RELRELOC8  = HUNK_RELOC8 ;
  1002.   HUNK_EXT      = 1007 ;
  1003.   HUNK_SYMBOL      = 1008 ;
  1004.   HUNK_DEBUG      = 1009 ;
  1005.   HUNK_END      = 1010 ;
  1006.   HUNK_HEADER      = 1011 ;
  1007.  
  1008.   HUNK_OVERLAY      = 1013 ;
  1009.   HUNK_BREAK      = 1014 ;
  1010.  
  1011.   HUNK_DREL32      = 1015 ;
  1012.   HUNK_DREL16      = 1016 ;
  1013.   HUNK_DREL8      = 1017 ;
  1014.  
  1015.   HUNK_LIB       = 1018 ;
  1016.   HUNK_INDEX      = 1019 ;
  1017.  
  1018. (* Note: V37 LoadSeg uses 1015 (HUNK_DREL32) by mistake.  This will continue  *)
  1019. (* to be supported in future versions, since HUNK_DREL32 is illegal in load   *)
  1020. (* files anyways.  Future versions will support both 1015 and 1020, though    *)
  1021. (* anything that should be usable under V37 should use 1015.              *)
  1022.  
  1023.   HUNK_RELOC32SHORT = 1020 ;
  1024.  
  1025. (* see ext_xxx below. New for V39 (note that LoadSeg only handles RELRELOC32).*)
  1026.   HUNK_RELRELOC32 = 1021 ;
  1027.   HUNK_ABSRELOC16 = 1022 ;
  1028.  
  1029.  
  1030. (* Any hunks that have the HUNKB_ADVISORY bit set will be ignored if they    *)
  1031. (* aren't understood.  When ignored, they're treated like HUNK_DEBUG hunks.  *)
  1032. (* NOTE: this handling of HUNKB_ADVISORY started as of V39 dos.library!  If  *)
  1033. (* lading such executables is attempted under <V39 dos, it will fail with a  *)
  1034. (* bad hunk type.                                 *)
  1035.  
  1036.   HUNKB_ADVISORY = 29 ; HUNKF_ADVISORY = {29} ;
  1037.   HUNKB_CHIP     = 30 ; HUNKF_CHIP     = {30} ;
  1038.   HUNKB_FAST     = 31 ; HUNKF_FAST     = {31} ;
  1039.  
  1040. (* hunk_ext sub-types *)
  1041.   EXT_SYMB     = 0 ;    (* symbol table                *)
  1042.   EXT_DEF    = 1 ;    (* relocatable definition        *)
  1043.   EXT_ABS    = 2 ;    (* Absolute definition            *)
  1044.   EXT_RES    = 3 ;    (* no longer supported            *)
  1045.   EXT_REF32    = 129 ;    (* 32 bit absolute reference to symbol    *)
  1046.   EXT_ABSREF32  = EXT_REF32 ;
  1047.   EXT_COMMON    = 130 ;    (* 32 bit absolute reference to COMMON block    *)
  1048.   EXT_ABSCOMMON    = EXT_COMMON ;
  1049.   EXT_REF16    = 131 ;    (* 16 bit PC-relative reference to symbol    *)
  1050.   EXT_RELREF16  = EXT_REF16 ;
  1051.   EXT_REF8    = 132 ;    (*  8 bit PC-relative reference to symbol    *)
  1052.   EXT_RELREF8   = EXT_REF8 ;
  1053.   EXT_DEXT32    = 133 ;    (* 32 bit data relative reference *)
  1054.   EXT_DEXT16    = 134 ;    (* 16 bit data relative reference *)
  1055.   EXT_DEXT8    = 135 ;    (*  8 bit data relative reference *)
  1056.  
  1057. (* These are to support some of the '020 and up modes that are rarely used *)
  1058.   EXT_RELREF32    = 136 ;    (* 32 bit PC-relative reference to symbol       *)
  1059.   EXT_RELCOMMON    = 137 ;    (* 32 bit PC-relative reference to COMMON block    *)
  1060.  
  1061. (* for completeness... All 680x0's support this *)
  1062.   EXT_ABSREF16    = 138 ;    (* 16 bit absolute reference to symbol        *)
  1063.  
  1064. (* this only exists on '020's and above, in the (d8,An,Xn) address mode *)
  1065.   EXT_ABSREF8     = 139 ;    (* 8 bit absolute reference to symbol        *)
  1066.  
  1067.  
  1068. (*----------------------------------------------------------------------------*)
  1069. (* definitions for the System() call *)
  1070.  
  1071. CONST
  1072.   SYS_Dummy        = (TAG_USER + 32) ;
  1073.  
  1074.   SYS_Input        = (SYS_Dummy + 1) ;
  1075.             (* specifies the input filehandle  *)
  1076.  
  1077.   SYS_Output        = (SYS_Dummy + 2) ;
  1078.             (* specifies the output filehandle *)
  1079.  
  1080.   SYS_Asynch        = (SYS_Dummy + 3) ;
  1081.             (* run asynch, close input/output on exit(!)    *)
  1082.  
  1083.   SYS_UserShell        = (SYS_Dummy + 4) ;
  1084.             (* send to user shell instead of boot shell    *)
  1085.  
  1086.   SYS_CustomShell    = (SYS_Dummy + 5) ;
  1087.             (* send to a specific shell (data is name)    *)
  1088. (* SYS_Error, *)
  1089.  
  1090. (*---------------------------------------------------------------------------*)
  1091. (* definitions for the CreateNewProc() call                     *)
  1092. (* you MUST specify one of NP_Seglist or NP_Entry.  All else is optional.    *)
  1093.  
  1094.    NP_Dummy           = (TAG_USER + 1000) ;
  1095.  
  1096.    NP_Seglist         = (NP_Dummy + 1) ;
  1097.             (* seglist of code to run for the process  *)
  1098.  
  1099.    NP_FreeSeglist     = (NP_Dummy + 2) ;
  1100.             (* free seglist on exit - only valid for   *)
  1101.             (* for NP_Seglist.  Default is TRUE.       *)
  1102.  
  1103.    NP_Entry         = (NP_Dummy + 3) ;
  1104.             (* entry point to run - mutually exclusive *)
  1105.             (* with NP_Seglist! *)
  1106.  
  1107.    NP_Input         = (NP_Dummy + 4) ;
  1108.             (* filehandle - default is Open("NIL:"...) *)
  1109.  
  1110.    NP_Output        = (NP_Dummy + 5) ;
  1111.             (* filehandle - default is Open("NIL:"...) *)
  1112.  
  1113.    NP_CloseInput    = (NP_Dummy + 6) ;
  1114.             (* close input filehandle on exit       *)
  1115.             (* default TRUE                   *)
  1116.  
  1117.    NP_CloseOutput    = (NP_Dummy + 7) ;
  1118.             (* close output filehandle on exit       *)
  1119.             (* default TRUE                   *)
  1120.  
  1121.    NP_Error        = (NP_Dummy + 8) ;
  1122.             (* filehandle - default is Open("NIL:"...) *)
  1123.  
  1124.    NP_CloseError    = (NP_Dummy + 9) ;
  1125.             (* close error filehandle on exit       *)
  1126.             (* default TRUE                   *)
  1127.  
  1128.    NP_CurrentDir    = (NP_Dummy + 10) ;
  1129.             (* lock - default is parent's current dir  *)
  1130.  
  1131.    NP_StackSize        = (NP_Dummy + 11) ;
  1132.             (* stacksize for process - default 4000    *)
  1133.  
  1134.    NP_Name        = (NP_Dummy + 12) ;
  1135.             (* name for process - default "New Process"*)
  1136.  
  1137.    NP_Priority        = (NP_Dummy + 13) ;
  1138.             (* priority - default same as parent       *)
  1139.  
  1140.    NP_ConsoleTask    = (NP_Dummy + 14) ;
  1141.             (* consoletask - default same as parent    *)
  1142.  
  1143.    NP_WindowPtr        = (NP_Dummy + 15) ;
  1144.             (* window ptr - default is same as parent  *)
  1145.  
  1146.    NP_HomeDir        = (NP_Dummy + 16) ;
  1147.             (* home directory - default curr home dir  *)
  1148.  
  1149.    NP_CopyVars        = (NP_Dummy + 17) ;
  1150.             (* boolean to copy local vars-default TRUE *)
  1151.  
  1152.    NP_Cli        = (NP_Dummy + 18) ;
  1153.             (* create cli structure - default FALSE    *)
  1154.  
  1155.    NP_Path        = (NP_Dummy + 19) ;
  1156.             (* path - default is copy of parents path  *)
  1157.             (* only valid if a cli process!       *)
  1158.  
  1159.    NP_CommandName    = (NP_Dummy + 20) ;
  1160.             (* commandname - valid only for CLI       *)
  1161.  
  1162.    NP_Arguments        = (NP_Dummy + 21) ;
  1163.  
  1164. (* cstring of arguments - passed with str in a0, length in d0.    *)
  1165. (* (copied and freed on exit.)    Default is 0-length NULL ptr.    *)
  1166. (* NOTE: not operational until V37 - see BIX/TechNotes for    *)
  1167. (* more info/workaround.  In V36, the registers were random.    *)
  1168. (* You must NEVER use NP_Arguments with a NP_Input of NULL.    *)
  1169.  
  1170. (* FIX! should this be only for cli's? *)
  1171.  
  1172.    NP_NotifyOnDeath    = (NP_Dummy + 22) ;
  1173.             (* notify parent on death - default FALSE  *)
  1174.             (* Not functional yet. *)
  1175.  
  1176.    NP_Synchronous    = (NP_Dummy + 23) ;
  1177.             (* don't return until process finishes -   *)
  1178.             (* default FALSE.               *)
  1179.             (* Not functional yet. *)
  1180.  
  1181.    NP_ExitCode        = (NP_Dummy + 24) ;
  1182.             (* code to be called on process exit       *)
  1183.  
  1184.    NP_ExitData        = (NP_Dummy + 25) ;
  1185.             (* optional argument for NP_EndCode rtn -  *)
  1186.             (* default NULL                   *)
  1187.  
  1188.  
  1189. (*----------------------------------------------------------------------------*)
  1190. (* tags for AllocDosObject *)
  1191.  
  1192.   ADO_Dummy        = (TAG_USER + 2000) ;
  1193.  
  1194.   ADO_FH_Mode        = (ADO_Dummy + 1) ;
  1195.     (* for type DOS_FILEHANDLE only               *)
  1196.     (* sets up FH for mode specified.           *)
  1197.     (* This can make a big difference for buffered *)
  1198.     (* files.                       *)
  1199.  
  1200.     (* The following are for DOS_CLI *)
  1201.     (* If you do not specify these, dos will use it's preferred values *)
  1202.     (* which may change from release to release.  The BPTRs to these   *)
  1203.     (* will be set up correctly for you.  Everything will be zero,       *)
  1204.     (* except cli_FailLevel (10) and cli_Background (DOSTRUE).       *)
  1205.     (* NOTE: you may also use these 4 tags with CreateNewProc.       *)
  1206.  
  1207.    ADO_DirLen        = (ADO_Dummy + 2) ;
  1208.             (* size in bytes for current dir buffer    *)
  1209.  
  1210.    ADO_CommNameLen    = (ADO_Dummy + 3) ;
  1211.             (* size in bytes for command name buffer   *)
  1212.  
  1213.    ADO_CommFileLen    = (ADO_Dummy + 4) ;
  1214.             (* size in bytes for command file buffer   *)
  1215.  
  1216.    ADO_PromptLen    = (ADO_Dummy + 5) ;
  1217.             (* size in bytes for the prompt buffer       *)
  1218.  
  1219. (*----------------------------------------------------------------------------*)
  1220. (* tags for NewLoadSeg                                    *)
  1221. (* no tags are defined yet for NewLoadSeg                      *)
  1222.  
  1223. (* NOTE: V37 dos.library, when doing ExAll() emulation, and V37 filesystems  *)
  1224. (* will return an error if passed ED_OWNER.  If you get ERROR_BAD_NUMBER,    *)
  1225. (* retry with ED_COMMENT to get everything but owner info.  All filesystems  *)
  1226. (* supporting ExAll() must support through ED_COMMENT, and must check Type   *)
  1227. (* and return ERROR_BAD_NUMBER if they don't support the type.             *)
  1228.  
  1229. (* values that can be passed for what data you want from ExAll() *)
  1230. (* each higher value includes those below it (numerically)     *)
  1231. (* you MUST chose one of these values *)
  1232.  
  1233. CONST
  1234.   ED_NAME    = 1 ;
  1235.   ED_TYPE    = 2 ;
  1236.   ED_SIZE    = 3 ;
  1237.   ED_PROTECTION    = 4 ;
  1238.   ED_DATE    = 5 ;
  1239.   ED_COMMENT    = 6 ;
  1240.   ED_OWNER    = 7 ;
  1241.  
  1242. (* Structure in which exall results are returned in. Note that only the *)
  1243. (* fields asked for will exist!                        *)
  1244.  
  1245. TYPE
  1246.   ExAllData = RECORD
  1247.     ed_Next : ExAllDataPtr ;
  1248.     ed_Name : STRING  ;
  1249.     ed_Type : LONGINT ;
  1250.     ed_Size : LONGINT ;
  1251.     ed_Prot : LONGINT ;
  1252.     ed_Days : LONGINT ;
  1253.     ed_Mins : LONGINT ;
  1254.     ed_Ticks: LONGINT ;
  1255.     ed_Comment  : STRING ;    (* strings will be after last used field *)
  1256.     ed_OwnerUID : CARDINAL ;    (* new for V39                 *)
  1257.     ed_OwnerGID : CARDINAL ;
  1258.   END ;
  1259.  
  1260. (*   Control structure passed to ExAll.  Unused fields MUST be initialized to *)
  1261. (*   0, expecially eac_LastKey.                              *)
  1262. (*                                          *)
  1263. (*   eac_MatchFunc is a hook (see utility.library documentation for usage)    *)
  1264. (*   It should return true if the entry is to returned, false if it is to be  *)
  1265. (*   ignored.                                      *)
  1266. (*                                          *)
  1267. (*   This structure MUST be allocated by AllocDosObject()!              *)
  1268.  
  1269. TYPE
  1270.   ExAllControl = RECORD
  1271.     eac_Entries     : LONGINT ;    (* number of entries returned in buffer       *)
  1272.     eac_LastKey     : LONGINT ;    (* Don't touch inbetween linked ExAll calls!  *)
  1273.     eac_MatchString : STRING  ; (* wildcard string for pattern match or NULL  *)
  1274.     eac_MatchFunc   : HookPtr ; (* optional private wildcard function         *)
  1275.   END ;
  1276.  
  1277. (* The disk "environment" is a longword array that describes the          *)
  1278. (* disk geometry.  It is variable sized, with the length at the beginning.    *)
  1279. (* Here are the constants for a standard geometry.                  *)
  1280.  
  1281.   DosEnvec = RECORD
  1282.     de_TableSize      : LONGINT ; (* Size of Environment vector              *)
  1283.     de_SizeBlock      : LONGINT ; (* in longwords: standard value is 128      *)
  1284.     de_SecOrg          : LONGINT ; (* not used; must be 0              *)
  1285.     de_Surfaces       : LONGINT ; (* # of heads (surfaces). drive specific    *)
  1286.     de_SectorPerBlock : LONGINT ; (* not used; must be 1              *)
  1287.     de_BlocksPerTrack : LONGINT ; (* blocks per track. drive specific          *)
  1288.     de_Reserved          : LONGINT ; (* DOS reserved blocks at start of partition*)
  1289.     de_PreAlloc       : LONGINT ; (* DOS reserved blocks at end of partition  *)
  1290.     de_Interleave     : LONGINT ; (* usually 0                      *)
  1291.     de_LowCyl          : LONGINT ; (* starting cylinder. typically 0          *)
  1292.     de_HighCyl        : LONGINT ; (* max cylinder. drive specific          *)
  1293.     de_NumBuffers     : LONGINT ; (* Initial # DOS of buffers.              *)
  1294.     de_BufMemType     : LONGINT ; (* type of mem to allocate for buffers      *)
  1295.     de_MaxTransfer    : LONGINT ; (* Max number of bytes to transfer at a time*)
  1296.     de_Mask          : LONGINT ; (* Address Mask to block out certain memory *)
  1297.     de_BootPri          : LONGINT ; (* Boot priority for autoboot              *)
  1298.     de_DosType          : LONGINT ; (* ASCII(HEX) string showing filesystem type*)
  1299.                       (* 0X444F5300 is old filesystem,          *)
  1300.                       (* 0X444F5301 is fast file system          *)
  1301.     de_Baud          : LONGINT ; (* Baud rate for serial handler          *)
  1302.     de_Control          : LONGINT ; (* Control word for handler/filesystem      *)
  1303.     de_BootBlocks     : LONGINT ; (* Number of blocks containing boot code    *)
  1304.  
  1305.   END ;
  1306.  
  1307. (* these are the offsets into the array                    *)
  1308. (* DE_TABLESIZE is set to the number of longwords in the table minus 1    *)
  1309.  
  1310. CONST
  1311.   DE_TABLESIZE       = 0 ; (* minimum value is 11 (includes NumBuffers)    *)
  1312.   DE_SIZEBLOCK       = 1 ; (* in longwords: standard value is 128        *)
  1313.   DE_SECORG       = 2 ; (* not used; must be 0                *)
  1314.   DE_NUMHEADS       = 3 ; (* # of heads (surfaces). drive specific    *)
  1315.   DE_SECSPERBLK       = 4 ; (* not used; must be 1                *)
  1316.   DE_BLKSPERTRACK  = 5 ; (* blocks per track. drive specific        *)
  1317.   DE_RESERVEDBLKS  = 6 ; (* unavailable blocks at start.usually 2    *)
  1318.   DE_PREFAC       = 7 ; (* not used; must be 0                *)
  1319.   DE_INTERLEAVE       = 8 ; (* usually 0                    *)
  1320.   DE_LOWCYL       = 9 ; (* starting cylinder. typically 0        *)
  1321.   DE_UPPERCYL       = 10; (* max cylinder.  drive specific        *)
  1322.   DE_NUMBUFFERS       = 11; (* starting # of buffers.  typically 5        *)
  1323.   DE_MEMBUFTYPE       = 12; (* type of mem to allocate for buffers.    *)
  1324.   DE_BUFMEMTYPE       = 12; (* same as above, better name
  1325.               * 1 is public, 3 is chip, 5 is fast        *)
  1326.   DE_MAXTRANSFER   = 13; (* Max number bytes to transfer at a time    *)
  1327.   DE_MASK       = 14; (* Address Mask to block out certain memory    *)
  1328.   DE_BOOTPRI       = 15; (* Boot priority for autoboot            *)
  1329.   DE_DOSTYPE       = 16; (* ASCII (HEX) string showing filesystem type  *)
  1330.              (* 0X444F5300 is old filesystem        *)
  1331.              (* 0X444F5301 is fast file system        *)
  1332.   DE_BAUD       = 17; (* Baud rate for serial handler        *)
  1333.   DE_CONTROL       = 18; (* Control word for handler/filesystem        *)
  1334.   DE_BOOTBLOCKS       = 19; (* Number of blocks containing boot code    *)
  1335.  
  1336. (* The file system startup message is linked into a device node's startup *)
  1337. (* field.  It contains a pointer to the above environment, plus the      *)
  1338. (* information needed to do an exec OpenDevice().              *)
  1339.  
  1340. TYPE
  1341.   FileSysStartupMsg = RECORD
  1342.     fssm_Unit    : LONGINT     ; (* exec unit number for this device          *)
  1343.     fssm_Device  : BSTRING     ; (* null terminated bstring to the device name*)
  1344.     fssm_Environ : DosEnvecPtr ; (* ptr to environment table (see above)      *)
  1345.     fssm_Flags   : LONGSET     ; (* flags for OpenDevice()              *)
  1346.   END ;
  1347.  
  1348.  
  1349. (* The include file "libraries/dosextens.h" has a DeviceList structure.    *)
  1350. (* The "device list" can have one of three different things linked onto    *)
  1351. (* it.    Dosextens defines the structure for a volume.  DLT_DIRECTORY    *)
  1352. (* is for an assigned directory.  The following structure is for    *)
  1353. (* a dos "device" (DLT_DEVICE).                        *)
  1354.  
  1355. TYPE
  1356.   DeviceNode = RECORD
  1357.     dn_Next : DeviceListPtr ;    (* singly linked list                  *)
  1358.     dn_Type : LONGINT  ;    (* always 0 for dos "devices"              *)
  1359.     dn_Task : MsgPortPtr ;    (* standard dos "task" field.  If this is     *)
  1360.                 (* null when the node is accesses, a task     *)
  1361.                 (* will be started up                  *)
  1362.     dn_Lock      : FileLockPtr;    (* not used for devices -- leave null          *)
  1363.     dn_Handler   : BSTRING  ;    (* filename to loadseg (if seglist is null)   *)
  1364.     dn_StackSize : LONGINT  ;    (* stacksize to use when starting task          *)
  1365.     dn_Priority  : LONGINT  ;    (* task priority when starting task          *)
  1366.     dn_Startup   : FileSysStartupMsgPtr ;
  1367.                     (* startup msg: FileSysStartupMsg for disks   *)
  1368.     dn_SegList   : BADDRESS ;    (* code to run to start new task,if necessary *)
  1369.                 (* if null then dn_Handler will be loaded.    *)
  1370.     dn_GlobalVec : BADDRESS ;    (* BCPL global vector to use when starting    *)
  1371.                 (* a task.  -1 means that dn_SegList is not   *)
  1372.                 (* for a bcpl program, so the dos won't          *)
  1373.                 (* try and construct one.  0 tell the          *)
  1374.                 (* dos that you obey BCPL linkage rules          *)
  1375.                 (* and that it should construct a global      *)
  1376.                 (* vector for you.                  *)
  1377.     dn_Name : BSTRING ;        (* the node name, e.g. '\3','D','F','3'          *)
  1378.   END ;
  1379.  
  1380. (* use of Class and code is discouraged for the time being - we might want to
  1381.    change things *)
  1382.  
  1383. (* --- NotifyMessage Class ------------------------------------------------ *)
  1384.  
  1385. CONST
  1386.   NOTIFY_CLASS = 040000000H ;
  1387.  
  1388. (* --- NotifyMessage Codes ------------------------------------------------ *)
  1389.  
  1390.   NOTIFY_CODE = 01234H ;
  1391.  
  1392.  
  1393. (* Sent to the application if SEND_MESSAGE is specified. *)
  1394.  
  1395. TYPE
  1396.   NotifyMessage = RECORD
  1397.     nm_ExecMessage : Message  ;
  1398.     nm_Class       : LONGINT  ;
  1399.     nm_Code       : CARDINAL ;
  1400.     nm_NReq       : NotifyRequestPtr ;    (* don't modify the request!          *)
  1401.     nm_DoNotTouch  : LONGINT  ;        (* like it says!  For use by handlers *)
  1402.     nm_DoNotTouch2 : LONGINT  ;        (* ditto                  *)
  1403.   END ;
  1404.  
  1405. (* Do not modify or reuse the notifyrequest while active.            *)
  1406. (* note: the first LONG of nr_Data has the length transfered            *)
  1407.  
  1408. TYPE
  1409.   NotifyRequest = RECORD
  1410.     nr_Name     : STRING  ;
  1411.     nr_FullName : STRING  ;    (* set by dos - don't touch *)
  1412.     nr_UserData : LONGINT ;    (* for applications use     *)
  1413.     nr_Flags    : LONGSET ;
  1414.  
  1415.     nr_stuff : RECORD
  1416.       CASE :INTEGER OF
  1417.       |0: nr_Msg  : RECORD
  1418.       nr_Port : MsgPortPtr ; (* for SEND_MESSAGE *)
  1419.         END ;
  1420.       |1: nr_Signal: RECORD
  1421.           nr_Task      : TaskPtr   ; (* for SEND_SIGNAL *)
  1422.       nr_SignalNum : SHORTCARD ; (* for SEND_SIGNAL *)
  1423.       nr_pad,nr_pad2,nr_pad3 : CHAR ;
  1424.         END ;
  1425.       END ;
  1426.     END ;
  1427.     nr_Reserved : ARRAY [0..3] OF LONGINT ; (* leave 0 for now *)
  1428.     (* internal use by handlers *)
  1429.     nr_MsgCount : LONGINT    ; (* # of outstanding msgs              *)
  1430.     nr_Handler  : MsgPortPtr ; (* handler sent to (for EndNotify) *)
  1431.   END ;
  1432.  
  1433. (* --- NotifyRequest Flags ------------------------------------------------ *)
  1434.  
  1435. CONST
  1436.   NRB_SEND_MESSAGE    = 0 ;  NRF_SEND_MESSAGE      = {0} ;
  1437.   NRB_SEND_SIGNAL    = 1 ;  NRF_SEND_SIGNAL      = {1} ;
  1438.   NRB_WAIT_REPLY    = 3 ;  NRF_WAIT_REPLY      = {3} ;
  1439.   NRB_NOTIFY_INITIAL    = 4 ;  NRF_NOTIFY_INITIAL = {4} ;
  1440.  
  1441. (* do NOT set or remove NRF_MAGIC!  Only for use by handlers! *)
  1442.   NRB_MAGIC        = 31 ; NRF_MAGIC      = {31} ;
  1443.  
  1444. (* bit numbers *)
  1445.  
  1446. (* Flags reserved for private use by the handler: *)
  1447.  
  1448.   NR_HANDLER_FLAGS = {16..31} ;
  1449.  
  1450.  
  1451. (*--------------------------------------------------------------------------
  1452.  *
  1453.  * The CSource data structure defines the input source for "ReadItem()"
  1454.  * as well as the ReadArgs call.  It is a publicly defined structure
  1455.  * which may be used by applications which use code that follows the
  1456.  * conventions defined for access.
  1457.  *
  1458.  * When passed to the dos.library functions, the value passed as
  1459.  * struct *CSource is defined as follows:
  1460.  *    if ( CSource == 0)    Use buffered IO "ReadChar()" as data source
  1461.  *    else            Use CSource for input character stream
  1462.  *
  1463.  * The following two pseudo-code routines define how the CSource structure
  1464.  * is used:
  1465.  *
  1466.  * long CS_ReadChar( struct CSource *CSource )
  1467.  *
  1468.  *    if ( CSource == 0 )    return ReadChar();
  1469.  *    if ( CSource->CurChr >= CSource->Length )    return ENDSTREAMCHAR;
  1470.  *    return CSource->Buffer[ CSource->CurChr++ ];
  1471.  *
  1472.  *
  1473.  * BOOL CS_UnReadChar( struct CSource *CSource )
  1474.  *
  1475.  *    if ( CSource == 0 )    return UnReadChar();
  1476.  *    if ( CSource->CurChr <= 0 )    return FALSE;
  1477.  *    CSource->CurChr--;
  1478.  *    return TRUE;
  1479.  *
  1480.  *
  1481.  * To initialize a struct CSource, you set CSource->CS_Buffer to
  1482.  * a string which is used as the data source, and set CS_Length to
  1483.  * the number of characters in the string.  Normally CS_CurChr should
  1484.  * be initialized to ZERO, or left as it was from prior use as
  1485.  * a CSource.
  1486.  *
  1487.  *---------------------------------------------------------------------*)
  1488.  
  1489. TYPE
  1490.   CSource = RECORD
  1491.     CS_Buffer : POINTER TO ARRAY OF CHAR ;
  1492.     CS_Length : LONGINT ;
  1493.     CS_CurChr : LONGINT ;
  1494.   END ;
  1495.  
  1496. (*----------------------------------------------------------------------
  1497.  *
  1498.  * The RDArgs data structure is the input parameter passed to the DOS
  1499.  * ReadArgs() function call.
  1500.  *
  1501.  * The RDA_Source structure is a CSource as defined above;
  1502.  * if RDA_Source.CS_Buffer is non-null, RDA_Source is used as the input
  1503.  * character stream to parse, else the input comes from the buffered STDIN
  1504.  * calls ReadChar/UnReadChar.
  1505.  *
  1506.  * RDA_DAList is a private address which is used internally to track
  1507.  * allocations which are freed by FreeArgs().  This MUST be initialized
  1508.  * to NULL prior to the first call to ReadArgs().
  1509.  *
  1510.  * The RDA_Buffer and RDA_BufSiz fields allow the application to supply
  1511.  * a fixed-size buffer in which to store the parsed data.  This allows
  1512.  * the application to pre-allocate a buffer rather than requiring buffer
  1513.  * space to be allocated.  If either RDA_Buffer or RDA_BufSiz is NULL,
  1514.  * the application has not supplied a buffer.
  1515.  *
  1516.  * RDA_ExtHelp is a text string which will be displayed instead of the
  1517.  * template string, if the user is prompted for input.
  1518.  *
  1519.  * RDA_Flags bits control how ReadArgs() works.  The flag bits are
  1520.  * defined below.  Defaults are initialized to ZERO.
  1521.  *
  1522.  *---------------------------------------------------------------------*)
  1523.  
  1524. TYPE
  1525.   RDArgs = RECORD
  1526.     RDA_Source  : CSource ; (* Select input source          *)
  1527.     RDA_DAList  : LONGINT ; (* PRIVATE.                  *)
  1528.     RDA_Buffer  : STRING  ; (* Optional string parsing space. *)
  1529.     RDA_BufSiz  : LONGINT ; (* Size of RDA_Buffer (0..n)      *)
  1530.     RDA_ExtHelp : ADDRESS ; (* Optional extended help          *)
  1531.     RDA_Flags   : LONGSET ; (* Flags for any required control *)
  1532.   END ;
  1533.  
  1534. CONST
  1535.   RDAB_STDIN    =  0  ;    (* Use "STDIN" rather than "COMMAND LINE"    *)
  1536.   RDAF_STDIN    = {0} ;
  1537.   RDAB_NOALLOC    =  1  ;    (* If set, do not allocate extra string space.    *)
  1538.   RDAF_NOALLOC    = {1} ;
  1539.   RDAB_NOPROMPT    =  2  ;    (* Disable reprompting for string input}.    *)
  1540.   RDAF_NOPROMPT    = {2} ;
  1541.  
  1542. (* Maximum number of template keywords which can be in a template passed *)
  1543. (* to ReadArgs(). IMPLEMENTOR NOTE - must be a multiple of 4.         *)
  1544.  
  1545.  
  1546. CONST
  1547.   MAX_TEMPLATE_ITEMS = 100 ;
  1548.  
  1549. (* Maximum number of MULTIARG items returned by ReadArgs(), before     *)
  1550. (* an ERROR_LINE_TOO_LONG.  These two limitations are due to stack     *)
  1551. (* usage.  Applications should allow "a lot" of stack to use ReadArgs(). *)
  1552.  
  1553. CONST
  1554.   MAX_MULTIARGS    = 128 ;
  1555.  
  1556. (* Modes for LockRecord/LockRecords() *)
  1557.  
  1558. CONST
  1559.   REC_EXCLUSIVE        = 0 ;
  1560.   REC_EXCLUSIVE_IMMED    = 1 ;
  1561.   REC_SHARED        = 2 ;
  1562.   REC_SHARED_IMMED    = 3 ;
  1563.  
  1564. (* struct to be passed to LockRecords()/UnLockRecords() *)
  1565.  
  1566. TYPE
  1567.   RecordLock = RECORD
  1568.     rec_FH     : FileHandlePtr    ; (* filehandle             *)
  1569.     rec_Offset : LONGINT    ; (* offset in file         *)
  1570.     rec_Length : LONGINT    ; (* length of file to be locked *)
  1571.     rec_Mode   : LONGINT    ; (* Type of lock         *)
  1572.   END ;
  1573.  
  1574.  
  1575. (* the structure in the pr_LocalVars list                *)
  1576. (* Do NOT allocate yourself, use SetVar()!!! This structure may grow in *)
  1577. (* future releases!  The list should be left in alphabetical order, and *)
  1578. (* may have multiple entries with the same name but different types.    *)
  1579.  
  1580. TYPE
  1581.   LocalVar = RECORD
  1582.     lv_Node  : Node    ;
  1583.     lv_Flags : BITSET  ;
  1584.     lv_Value : ADDRESS ;
  1585.     lv_Len   : LONGINT ;
  1586.   END ;
  1587.  
  1588. (* The lv_Flags bits are available to the application.    The unused    *)
  1589. (* lv_Node.ln_Pri bits are reserved for system use.            *)
  1590.  
  1591. (* bit definitions for lv_Node.ln_Type: *)
  1592. CONST
  1593.   LV_VAR     = 0 ; (* an variable *)
  1594.   LV_ALIAS   = 1 ; (* an alias    *)
  1595. (* to be added into type: *)
  1596.   LVB_IGNORE =  7  ; (* ignore this entry on GetVar, etc *)
  1597.   LVF_IGNORE = 128 ;
  1598.  
  1599. (* definitions of flags passed to GetVar()/SetVar()/DeleteVar()           *)
  1600. (* bit defs to be OR'ed with the type:                       *)
  1601. (* item will be treated as a single line of text unless BINARY_VAR is used *)
  1602.  
  1603. CONST
  1604.   GVB_GLOBAL_ONLY    =  8   ;
  1605.   GVF_GLOBAL_ONLY    = {8}  ;
  1606.   GVB_LOCAL_ONLY     =  9   ;
  1607.   GVF_LOCAL_ONLY     = {9}  ;
  1608.   GVB_BINARY_VAR     =  10  ;
  1609.   GVF_BINARY_VAR     = {10} ; (* treat variable as binary*)
  1610.   GVB_DONT_NULL_TERM =  11  ; (* only with GVF_BINARY_VAR *)
  1611.   GVF_DONT_NULL_TERM = {11} ;
  1612.  
  1613. (* this is only supported in >= V39 dos.  V37 dos ignores this. *)
  1614. (* this causes SetVar to affect ENVARC: as well as ENV:.    *)
  1615.   GVB_SAVE_VAR =  12  ;
  1616.   GVF_SAVE_VAR = {12} ; (* only with GVF_GLOBAL_VAR *)
  1617.  
  1618. VAR
  1619.   DosBase : DosLibraryPtr ;
  1620.     (* M2: This is deliberately not declared as DOSBase in order to allow *)
  1621.     (* auto_init code to declare & open DOSBase, as required by the DICE  *)
  1622.     (* startup code.                              *)
  1623.  
  1624. PROCEDURE Open( name : STRING ; accessMode : LONGINT ) : FileHandlePtr ;
  1625. PROCEDURE Close( file : FileHandlePtr ) : LONGINT ;
  1626. PROCEDURE Read( file: FileHandlePtr ; buff: ADDRESS ; len: LONGINT ) : LONGINT ;
  1627. PROCEDURE Write( file: FileHandlePtr ; buff: ADDRESS ; len: LONGINT ): LONGINT ;
  1628. PROCEDURE Input( ) : FileHandlePtr ;
  1629. PROCEDURE Output( ) : FileHandlePtr ;
  1630. PROCEDURE Seek( file : FileHandlePtr ; position , offset : LONGINT ) : LONGINT ;
  1631. PROCEDURE DeleteFile( name : STRING ) : LONGINT ;
  1632. PROCEDURE Rename( oldName , newName : STRING ) : LONGINT ;
  1633. PROCEDURE Lock( name : STRING ; type : LONGINT ) : FileLockPtr ;
  1634. PROCEDURE UnLock( lock : FileLockPtr ) ;
  1635. PROCEDURE DupLock( lock : FileLockPtr ) : BSTRING ;
  1636. PROCEDURE Examine( lock : FileLockPtr ; VAR fibp : FileInfoBlock ) : LONGINT ;
  1637. PROCEDURE ExNext( lock : FileLockPtr ; VAR fibp : FileInfoBlock ) : LONGINT ;
  1638. PROCEDURE Info( lock : FileLockPtr ; VAR parameterBlock : InfoData ) : LONGINT ;
  1639. PROCEDURE CreateDir( name : STRING ) : FileLockPtr ;
  1640. PROCEDURE CurrentDir( lock : FileLockPtr ) : FileLockPtr ;
  1641. PROCEDURE IoErr( ) : LONGINT ;
  1642.  
  1643. PROCEDURE CreateProc( name    : STRING  ;
  1644.               pri    : LONGINT ;
  1645.               segList   : BADDRESS ;
  1646.               stackSize : LONGINT ) : MsgPortPtr ;
  1647.  
  1648. PROCEDURE Exit( returnCode : LONGINT ) ;
  1649. PROCEDURE LoadSeg( name : STRING ) : BADDRESS ;
  1650.  
  1651. PROCEDURE UnLoadSeg( seglist : BADDRESS ) ;
  1652. PROCEDURE DeviceProc( name : STRING ) : MsgPortPtr ;
  1653. PROCEDURE SetComment( name , comment : STRING ) : LONGINT ;
  1654. PROCEDURE SetProtection( name : STRING ; protect : LONGINT ) : LONGINT ;
  1655. PROCEDURE DateStamp( VAR date : DateStampRec ) : DateStampPtr ;
  1656. PROCEDURE Delay( timeout : LONGINT ) ;
  1657. PROCEDURE WaitForChar( file : FileHandlePtr ; timeout : LONGINT ) : LONGINT ;
  1658. PROCEDURE ParentDir( lock : FileLockPtr ) : FileLockPtr ;
  1659. PROCEDURE IsInteractive( file : FileHandlePtr ) : LONGINT ;
  1660. PROCEDURE Execute( string : STRING ; file , file2 : FileHandlePtr ) : LONGINT ;
  1661.  
  1662. (* ---- functions in V36 or higher (Release 2.0) ---- *)
  1663.      (*    DOS Object creation/deletion *)
  1664.  
  1665. PROCEDURE AllocDosObject( type : LONGINT ; tags : TagItemPtr ) : ADDRESS ;
  1666. PROCEDURE AllocDosObjectTagList( type : LONGINT ; tags: TagItemPtr ) : ADDRESS ;
  1667. PROCEDURE AllocDosObjectTags( type: LONGINT ; tag1type: LONGINT ;..) : ADDRESS ;
  1668. PROCEDURE FreeDosObject( type : LONGINT ; ptr : ADDRESS ) ;
  1669.  
  1670. (* ---- Packet Level routines ---- *)
  1671.  
  1672. PROCEDURE DoPkt ( port : MsgPortPtr ; action,a1,a2,a3,a4,a5 : LONGINT ):LONGINT;
  1673. PROCEDURE DoPkt0( port : MsgPortPtr ; action : LONGINT ) : LONGINT ;
  1674. PROCEDURE DoPkt1( port : MsgPortPtr ; action , arg1 : LONGINT ) : LONGINT ;
  1675. PROCEDURE DoPkt2( port : MsgPortPtr ; action, arg1, arg2 : LONGINT ) : LONGINT ;
  1676. PROCEDURE DoPkt3( port : MsgPortPtr ; action,a1,a2,a3 : LONGINT ) : LONGINT ;
  1677. PROCEDURE DoPkt4( port : MsgPortPtr ; action,a1,a2,a3,a4: LONGINT ) : LONGINT ;
  1678.  
  1679. PROCEDURE SendPkt( dp : DosPacketPtr ; port , replyport : MsgPortPtr ) ;
  1680.  
  1681. PROCEDURE WaitPkt ( ) : DosPacketPtr ;
  1682. PROCEDURE ReplyPkt( dp : DosPacketPtr ; res1 , res2 : LONGINT ) ;
  1683. PROCEDURE AbortPkt( port : MsgPortPtr ; pkt : DosPacketPtr );
  1684.  
  1685. (* ---- Record Locking ---- *)
  1686.  
  1687. PROCEDURE LockRecord( fh : FileHandlePtr ;
  1688.               offset,length,mode,long,timeout : LONGINT ) : BOOLEAN ;
  1689. PROCEDURE LockRecords ( recArray : RecordLockPtr ; timeout : LONGINT ) ;
  1690. PROCEDURE UnLockRecord( fh : FileHandlePtr ; offset, len : LONGINT ) : BOOLEAN ;
  1691. PROCEDURE UnLockRecords( recArray : RecordLockPtr ) : BOOLEAN ;
  1692.  
  1693. (* ---- Buffered File I/O ---- *)
  1694.  
  1695. PROCEDURE SelectInput( fh : FileHandlePtr ) : FileHandlePtr ;
  1696. PROCEDURE SelectOutput( fh : FileHandlePtr ) : FileHandlePtr ;
  1697. PROCEDURE FGetC( fh : FileHandlePtr ) : LONGINT ;
  1698. PROCEDURE FPutC( fh : FileHandlePtr ; ch : LONGINT ) : LONGINT ;
  1699. PROCEDURE UnGetC( fh : FileHandlePtr ; char : LONGINT ) : LONGINT ;
  1700.  
  1701. PROCEDURE FRead( fh : FileHandlePtr ;
  1702.          block : ADDRESS ;
  1703.          len, num : LONGINT ) : LONGINT ;
  1704.  
  1705. PROCEDURE FWrite( fh : FileHandlePtr ;
  1706.           block : ADDRESS ;
  1707.           len, num : LONGINT ): LONGINT ;
  1708.  
  1709. PROCEDURE FGets( fh : FileHandlePtr ; buf : STRING ; blen : LONGINT ) : STRING ;
  1710. PROCEDURE FPuts( fh : FileHandlePtr ; str : STRING ) : LONGINT ;
  1711. PROCEDURE VFWritef( fh : FileHandlePtr ; format : STRING ; argarray : ADDRESS );
  1712. PROCEDURE FWritef( fh : FileHandlePtr ; format : STRING ; .. ) ;
  1713.  
  1714. PROCEDURE VFPrintf( fh : FileHandlePtr ;
  1715.             format : STRING ;
  1716.             argarray : ADDRESS ) : LONGINT ;
  1717.  
  1718. PROCEDURE FPrintf( fh : FileHandlePtr ; format : STRING ; .. ) : LONGINT ;
  1719. PROCEDURE Flush( fh : FileHandlePtr ) : LONGINT ;
  1720. PROCEDURE SetVBuf( fh   : FileHandlePtr ;
  1721.            buff : ADDRESS ;
  1722.            type , size : LONGINT ) : LONGINT ;
  1723.  
  1724. (* ---- DOS Object Management ---- *)
  1725.  
  1726. PROCEDURE DupLockFromFH( fh : FileHandlePtr ) : FileLockPtr ;
  1727. PROCEDURE OpenFromLock( lock : FileLockPtr ) : FileHandlePtr ;
  1728. PROCEDURE ParentOfFH( fh : FileHandlePtr ) : FileLockPtr ;
  1729.  
  1730. PROCEDURE ExamineFH( fh : FileHandlePtr ; VAR fib : FileInfoBlock ) : BOOLEAN ;
  1731. PROCEDURE SetFileDate( name : STRING ; date : DateStampPtr ) : LONGINT ;
  1732.  
  1733. PROCEDURE NameFromLock( lock   : FileLockPtr ;
  1734.             buffer : STRING ;
  1735.             len    : LONGINT ) : LONGINT ;
  1736.  
  1737. PROCEDURE NameFromFH( fh     : FileHandlePtr ;
  1738.               buffer : STRING ;
  1739.               len    : LONGINT ) : LONGINT ;
  1740.  
  1741. PROCEDURE SplitName( name      : STRING  ;
  1742.              seperator : LONGINT ;
  1743.              buffer    : STRING  ;
  1744.              oldpos    : LONGINT ;
  1745.              size      : LONGINT ) : INTEGER ;
  1746.  
  1747. PROCEDURE SameLock( lock1 , lock2 : FileLockPtr ) : LONGINT ;
  1748.  
  1749. PROCEDURE SetMode( fh : FileHandlePtr ; mode : LONGINT );
  1750.  
  1751. PROCEDURE ExAll( lock : FileLockPtr  ;
  1752.          buff : ExAllDataPtr ;
  1753.          size , data : LONGINT ;
  1754.          control : ExAllControlPtr ) : LONGINT ;
  1755.  
  1756. PROCEDURE ReadLink( port : MsgPortPtr ;
  1757.             lock : FileLockPtr ;
  1758.             path , buffer : STRING ;
  1759.             size : LONGINT ) : LONGINT ;
  1760.  
  1761. PROCEDURE MakeLink( name : STRING ; dest , soft : LONGINT ) : LONGINT ;
  1762.  
  1763. PROCEDURE ChangeMode ( type : LONGINT ;
  1764.                fh : FileHandlePtr ;
  1765.                newmode : LONGINT ) : LONGINT ;
  1766.  
  1767. PROCEDURE SetFileSize( fh : FileHandlePtr ; pos , mode : LONGINT ) : LONGINT ;
  1768.  
  1769. (* ----- Error Handling ---- *)
  1770.  
  1771. PROCEDURE SetIoErr( result : LONGINT ) : LONGINT ;
  1772.  
  1773. PROCEDURE Fault( code : LONGINT ;
  1774.          header , buffer : STRING ;
  1775.          len : LONGINT ) : BOOLEAN ;
  1776.  
  1777. PROCEDURE PrintFault( code : LONGINT ; header : STRING ) : BOOLEAN ;
  1778. PROCEDURE ErrorReport( code,type,arg1: LONGINT ; device: MsgPortPtr ): LONGINT ;
  1779.  
  1780. (* ---- Process Management ---- *)
  1781.  
  1782. PROCEDURE Cli( ) : CommandLineInterfacePtr ;
  1783.  
  1784. PROCEDURE CreateNewProc( tags : TagItemPtr ) : ProcessPtr ;
  1785. PROCEDURE CreateNewProcTagList( tags : TagItemPtr ) : ProcessPtr ;
  1786. PROCEDURE CreateNewProcTags( tag1type : LONGINT ; .. ) : ProcessPtr ;
  1787.  
  1788. PROCEDURE RunCommand( seg      : BADDRESS ;
  1789.               stack    : LONGINT  ;
  1790.               paramptr : STRING   ;
  1791.               paramlen : LONGINT ) : LONGINT ;
  1792.  
  1793. PROCEDURE GetConsoleTask( ) : MsgPortPtr ;
  1794. PROCEDURE SetConsoleTask( task : MsgPortPtr ) : MsgPortPtr ;
  1795. PROCEDURE GetFileSysTask( ) : MsgPortPtr ;
  1796. PROCEDURE SetFileSysTask( task : MsgPortPtr ) : MsgPortPtr ;
  1797.  
  1798. PROCEDURE GetArgStr( ) : STRING ;
  1799. PROCEDURE SetArgStr( string : STRING ) : BOOLEAN ;
  1800. PROCEDURE FindCliProc( num : LONGINT ) : ProcessPtr ;
  1801.  
  1802. PROCEDURE MaxCli( ) : LONGINT ;
  1803.  
  1804. PROCEDURE SetCurrentDirName( name : STRING ) : BOOLEAN ;
  1805. PROCEDURE GetCurrentDirName( buf : STRING ; len : LONGINT ) : BOOLEAN ;
  1806.  
  1807. PROCEDURE SetProgramName( name : STRING ) : BOOLEAN ;
  1808. PROCEDURE GetProgramName( buf : STRING ; len : LONGINT ) : BOOLEAN ;
  1809.  
  1810. PROCEDURE SetPrompt( name : STRING ) : BOOLEAN ;
  1811. PROCEDURE GetPrompt( buf : STRING ; len : LONGINT ) : BOOLEAN ;
  1812.  
  1813. PROCEDURE SetProgramDir( lock : FileLockPtr ) : FileLockPtr ;
  1814. PROCEDURE GetProgramDir( ) : FileLockPtr ;
  1815.  
  1816. (* ---- Device List Management ---- *)
  1817.  
  1818. PROCEDURE SystemTagList( command : STRING ; tags : TagItemPtr ) : LONGINT ;
  1819. PROCEDURE System( command : STRING ; tags : TagItemPtr ) : LONGINT ;
  1820. PROCEDURE SystemTags( command : STRING ; tag1type : LONGINT ; .. ) : LONGINT ;
  1821.  
  1822. PROCEDURE AssignLock( name : STRING ; lock : FileLockPtr ) : LONGINT ;
  1823. PROCEDURE AssignLate( name : STRING ; path : STRING ) : BOOLEAN ;
  1824. PROCEDURE AssignPath( name : STRING ; path : STRING ) : BOOLEAN ;
  1825. PROCEDURE AssignAdd ( name : STRING ; lock : FileLockPtr ) : BOOLEAN ;
  1826. PROCEDURE RemAssignList( name : STRING ; lock : FileLockPtr ) : LONGINT ;
  1827.  
  1828. PROCEDURE GetDeviceProc( name : STRING ; dp : DevProcPtr ) : DevProcPtr ;
  1829. PROCEDURE FreeDeviceProc( dp : DevProcPtr ) ;
  1830.  
  1831. PROCEDURE LockDosList( flags : LONGSET ) : DosListPtr ;
  1832. PROCEDURE UnLockDosList( flags : LONGSET ) ;
  1833. PROCEDURE AttemptLockDosList( flags : LONGSET ) : DosListPtr ;
  1834. PROCEDURE RemDosEntry( dlist : DosListPtr ) : BOOLEAN ;
  1835. PROCEDURE AddDosEntry( dlist : DosListPtr ) : LONGINT ;
  1836.  
  1837. PROCEDURE FindDosEntry( dlist : DosListPtr ;
  1838.             name  : STRING ;
  1839.             flags : LONGSET ) : DosListPtr ;
  1840.  
  1841. PROCEDURE NextDosEntry( dlist : DosListPtr ; flags : LONGSET ) : DosListPtr ;
  1842. PROCEDURE MakeDosEntry( name : STRING ; type : LONGINT ) : DosListPtr ;
  1843. PROCEDURE FreeDosEntry( dlist : DosListPtr ) ;
  1844. PROCEDURE IsFileSystem( name : STRING ) : BOOLEAN ;
  1845.  
  1846. (* ---- Handler Interface ---- *)
  1847.  
  1848. PROCEDURE Format( filesystem,volumename: STRING ; dostype: LONGINT ): BOOLEAN ;
  1849. PROCEDURE Relabel( drive , newname : STRING ) : LONGINT ;
  1850. PROCEDURE Inhibit( name : STRING ; onoff : LONGINT ) ;
  1851. PROCEDURE AddBuffers( name : STRING ; number : LONGINT ) : LONGINT ;
  1852.  
  1853. (* ---- Date, Time Routines ---- *)
  1854.  
  1855. PROCEDURE CompareDates( date1 , date2 : DateStampPtr ) : LONGINT ;
  1856. PROCEDURE DateToStr( VAR datetime : DateTime ) : LONGINT ;
  1857. PROCEDURE StrToDate( VAR datetime : DateTime ) : LONGINT ;
  1858.  
  1859. (* ---- Image Management ---- *)
  1860.  
  1861. PROCEDURE InternalLoadSeg( fh    : FileHandlePtr ;
  1862.                table : BADDRESS ;
  1863.                funcarray , stack : ADDRESS ) : BADDRESS ;
  1864.  
  1865. PROCEDURE InternalUnLoadSeg( seglist : BADDRESS ; freefunc : PROC ) : BOOLEAN ;
  1866.  
  1867. PROCEDURE NewLoadSeg( file : STRING ; tags : TagItemPtr ) : BADDRESS ;
  1868. PROCEDURE NewLoadSegTagList( file : STRING ; tags : TagItemPtr ) : BADDRESS ;
  1869. PROCEDURE NewLoadSegTags( file : STRING ; tag1type : LONGINT ; .. ) : BADDRESS ;
  1870.  
  1871. PROCEDURE AddSegment( name: STRING ; seg: BADDRESS ; system: LONGINT ): LONGINT;
  1872.  
  1873. PROCEDURE FindSegment( name   : STRING ;
  1874.                seg    : SegmentPtr ;
  1875.                system : LONGINT ) : SegmentPtr ;
  1876.  
  1877. PROCEDURE RemSegment( seg : SegmentPtr ) : LONGINT ;
  1878.  
  1879. (* ---- Command Support ---- *)
  1880.  
  1881. PROCEDURE CheckSignal( mask : LONGSET ) : LONGSET ;
  1882.  
  1883. PROCEDURE ReadArgs( arg_template : STRING  ;
  1884.             array     : ADDRESS ;
  1885.             args     : RDArgsPtr ) : RDArgsPtr ;
  1886.  
  1887. PROCEDURE FindArg( keyword , arg_template : STRING ) : LONGINT ;
  1888.  
  1889. PROCEDURE ReadItem( name     : STRING ;
  1890.             maxchars : LONGINT ;
  1891.             csource  : CSourcePtr ) : LONGINT ;
  1892.  
  1893. PROCEDURE StrToLong( string : STRING ; VAR value : LONGINT ) : LONGINT ;
  1894. PROCEDURE MatchFirst( pat: STRING ; anchor : AnchorPathPtr ) : LONGINT ;
  1895.  
  1896. PROCEDURE MatchNext( anchor : AnchorPathPtr ) : LONGINT ;
  1897. PROCEDURE MatchEnd( anchor : AnchorPathPtr );
  1898. PROCEDURE ParsePattern( pat, buf : STRING ; buflen : LONGINT ) : LONGINT ;
  1899. PROCEDURE MatchPattern( pat, str : BOOLEAN ) : BOOLEAN ;
  1900. PROCEDURE FreeArgs( args : RDArgsPtr ) ;
  1901. PROCEDURE FilePart( path : STRING ) : STRING ;
  1902. PROCEDURE PathPart( path : STRING ) : STRING ;
  1903. PROCEDURE AddPart( dirname,filename : STRING ; size : LONGINT ) : BOOLEAN ;
  1904.  
  1905. (* ---- Notification ---- *)
  1906.  
  1907. PROCEDURE StartNotify( notify : NotifyRequestPtr ) : BOOLEAN ;
  1908. PROCEDURE EndNotify  ( notify : NotifyRequestPtr ) ;
  1909.  
  1910. (* ---- Environment Variable functions ----- *)
  1911.  
  1912. PROCEDURE SetVar( name,buffer:STRING ; size:LONGINT ; flags:LONGSET ) : BOOLEAN;
  1913. PROCEDURE GetVar( name,buffer:STRING ; size:LONGINT ; flags:LONGSET ) : LONGINT;
  1914. PROCEDURE DeleteVar( name : STRING ; flags : LONGSET ) : LONGINT ;
  1915. PROCEDURE FindVar( name : STRING ; type : LONGINT ) : LocalVarPtr ;
  1916.  
  1917. PROCEDURE CliInitNewcli( dp : DosPacketPtr ) : LONGINT ;
  1918. PROCEDURE CliInitRun( dp : DosPacketPtr ) : LONGINT ;
  1919.  
  1920. PROCEDURE WriteChars( buf : STRING ; buflen : LONGINT ) : LONGINT ;
  1921. PROCEDURE PutStr( str : STRING ) : LONGINT ;
  1922. PROCEDURE VPrintf( format : STRING ; argarray : ADDRESS ) : LONGINT ;
  1923. PROCEDURE Printf( format : STRING ; .. ) : LONGINT ;
  1924.  
  1925. (* these were unimplemented until dos 36.147 *)
  1926.  
  1927. PROCEDURE ParsePatternNoCase( pat, buf : STRING ; buflen : LONGINT ) : LONGINT ;
  1928. PROCEDURE MatchPatternNoCase( pat, str : STRING ) : BOOLEAN ;
  1929.  
  1930. (* this was added for V37 dos, returned 0 before then. *)
  1931.  
  1932. PROCEDURE SameDevice( lock1 , lock2 : FileLockPtr ) : BOOLEAN ;
  1933.  
  1934. (* NOTE: the following entries did NOT exist before ks 36.303 (2.02)    *)
  1935. (* If you are going to use them, open dos.library with version 37    *)
  1936.  
  1937. (* These calls were added for V39 dos: *)
  1938.  
  1939. PROCEDURE ExAllEnd( lock : FileLockPtr ;
  1940.             buffer : ADDRESS ;
  1941.             size , data : LONGINT ;
  1942.             control : ExAllControlPtr ) ;
  1943.  
  1944. PROCEDURE SetOwner( name : STRING ; owner_info : LONGINT ) : BOOLEAN ;
  1945.  
  1946. END Dos.
  1947.